Home > php教程 > php手册 > 顺丰BSP接口SOAP的请求示例

顺丰BSP接口SOAP的请求示例

WBOY
Release: 2016-06-06 20:13:43
Original
1321 people have browsed it

顺丰BSP接口SOAP的请求示例 在一些接口的设计中有时用到了SOAP方式的请求,比如顺丰BSP的接口。 我尝试不同方式的POST方式请求,要么完全请求不到东西,要么接收到乱码,均以失败告终。 针对顺丰接口的SOAP请求的核心代码分享如下: /** * 发送soap请求 */ p

顺丰BSP接口SOAP的请求示例

在一些接口的设计中有时用到了SOAP方式的请求,比如顺丰BSP的接口。
我尝试不同方式的POST方式请求,要么完全请求不到东西,要么接收到乱码,均以失败告终。

针对顺丰接口的SOAP请求的核心代码分享如下:

/**
* 发送soap请求
*/
private function _soap()
{
$client = new SoapClient($this->serviceUrl);
$info = new stdClass();
$info->arg0 = $this->xml;
$param = array($info);
$response = $client->__call(“sfexpressService”,$param);
return $response->return ;
}

/**
* 拼接出请求的xml
*/
public function createXml()
{
$xml = ‘
’.$this->user.’,’.$this->passWord.’

invoice_no.’” />

’;
$this->xml = $xml;
}

提示:
1.$this->serviceUrl 顺丰分配的BSP请求地址,注意是?wsdl的地址
2.$this->user,$this->passWord 即是顺丰分配的ID和校验码
3.返回的return是一个XML的String,你可能需要simplexml_load_string来解析。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template