对接ems的时候遇到,因为没接触过,一脸懵逼......
先贴代码
$dir = getcwd();
$pem = $dir.'/client.pem';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->serverEMSURL);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); //是否验证证书
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false); //是否验证host
curl_setopt($ch,CURLOPT_SSLCERT ,$pem);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_data);
curl_setopt($ch, CURLOPT_HEADER, 0);
$res = curl_exec($ch);
$sn = str_replace('GBK','UTF8',$res);
$xml = new \DOMDocument();
$xml->preserveWhiteSpace=false;
$xml->loadXML($sn);
curl_close($ch);
主要就是这么发送请求,.
private function getLogistice_Xml($sn,$order = '')
{
$xmlstr = <<<XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://web.webservice.busines.routdata.com">
<soapenv:Body>
<web:call>
<web:in0><?xml version="1.0" encoding="utf-8"?><MSG><HEAD><SYS_CODE>1047</SYS_CODE><USERNAME>参数</USERNAME><PASSWORD>参数</PASSWORD><FUNC_CODE>参数</FUNC_CODE></HEAD><BODY datasets="参数"><DATASET ds_id="参数" rows="参数" cols="参数"><ROW><COL col_name="参数">参数</COL></ROW></DATASET></BODY></MSG></web:in0>
</web:call>
</soapenv:Body>
</soapenv:Envelope>
XML;
return $xmlstr;
}
以上这个xml的结构是用soapUI这个软件生成的,
生成出来是这个样子的,问号里面填要发送的参数
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://web.webservice.busines.routdata.com">
<soapenv:Body>
<web:call>
<web:in0>?</web:in0>
</web:call>
</soapenv:Body>
</soapenv:Envelope>
当时遇到的主要问题是,能连接上wsdl的webService,但是不知道怎么调用他的call方法,后面发现soap找了好久找到soapUI这个软件...然后找到一篇文章说要把尖括号转码...