直接上代码了。
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
POST /AirLogisticsAPP/AirLogisticsService.asmx HTTP/1.1
Host: 58.213.128.130
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://58.213.128.130/HelloWorld"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld xmlns="http://58.213.128.130/" />
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorldResponse xmlns="http://58.213.128.130/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>
/**
* 使用curl发送post请求
* @param $url
* @param string $data
* @return bool|mixed
*/
public function sendCurlPost($url, $header = '', $post){
//初始化,创建一个cURL资源
$ch = curl_init();
//设置cURL选项
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "user-agent:Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0");
curl_setopt($ch, CURLOPT_HEADER, 0); //是否返回文件头信息
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //不直接打印输出
curl_setopt($ch, CURLOPT_POST, 1); //是否post请求
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); //post传输数据
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
//执行cURL会话
$response = curl_exec($ch);
file_put_contents("log11ss.txt", $response);
if (!curl_errno($ch)){
$result = $response;
}else{
// echo 'Curl error: ' . curl_error($ch);
$result = false;
}
//关闭cURL释放资源
curl_close($ch);
return $result;
}
public function ceshiweb()
{
$url = "http://58.213.128.130:888/AirLogisticsAPP/AirLogisticsService.asmx";
$header[] = "Content-type: text/xml";
$post = "<?xml version='1.0' encoding='utf-8'?>
<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Header>
<AuthHeaderNKG xmlns='http://58.213.128.130/'>
<IATACode>xxx</IATACode>
<LoginID>xxx</LoginID>
<Password>xxxxxx</Password>
</AuthHeaderNKG>
</soap:Header>
<soap:Body>
<CGOGetAWBInformation xmlns='http://58.213.128.130/'>
<AWBNumber>618609556xx</AWBNumber>
<AWBType>IO</AWBType>
</CGOGetAWBInformation>
</soap:Body>
</soap:Envelope>";
$res = $this->sendCurlPost($url,$header,$post);
print_r($res);die;
}