PHP中的Soap客户端
大家好,有人能解释我在PHP中实现下面的SOAP XML吗?我看到一些问题是使用CURL处理的,但我想在PHP中使用SOAP客户端库。有人能帮我吗 我看到一些人在PHP中使用下面的代码获得简单的SOAP,我如何在代码中实现相同的方法PHP中的Soap客户端,php,soap,Php,Soap,大家好,有人能解释我在PHP中实现下面的SOAP XML吗?我看到一些问题是使用CURL处理的,但我想在PHP中使用SOAP客户端库。有人能帮我吗 我看到一些人在PHP中使用下面的代码获得简单的SOAP,我如何在代码中实现相同的方法 <?php //Create the client object $soapclient = new SoapClient('http://www.example.com:8080/test/services/test?wsdl'); //Use the
<?php
//Create the client object
$soapclient = new SoapClient('http://www.example.com:8080/test/services/test?wsdl');
//Use the functions of the client, the params of the function are in
//the associative array
$params = array(
'locationID' => '19087525238255',
'custFirstName' => 'Seure',
'custLastName' => 'Install',
'customerType' => 'RESI'
);
$response = $soapclient->octService($params);
var_dump($response);
?>
soapxml
<soapenv:Envelope xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:com = "http://test.com/">
<soapenv:Header/>
<soapenv:Body>
<com:OCTService>
<locationID>19087525238255</locationID>
<customer>
<custFirstName>JOHN</custFirstName>
<custLastName>ADAM</custLastName>
<customerType>RESI</customerType>
</customer>
<order>
<orderScheduleType>NoSchedule</orderScheduleType>
<orderScheduledate/>
<reasonCode>NT</reasonCode>
<salesRep>0001</salesRep>
</order>
<Equipments>
<equipment>
<serialNumber>*</serialNumber>
<type>N</type>
</equipment>
<equipment>
<serialNumber>*</serialNumber>
<type>NH</type>
</equipment>
<equipment>
<serialNumber>*</serialNumber>
<type>NH</type>
</equipment>
</Equipments>
<csgServiceCodes>
<CSGServiceCode>
<rateCode>SR002</rateCode>
<packageCode/>
</CSGServiceCode>
<CSGServiceCode>
<rateCode>BA</rateCode>
<packageCode/>
</CSGServiceCode>
</csgServiceCodes>
<voiceFeatures>
<nativeNumbersCount>0</nativeNumbersCount>
<portedNmbers>?</portedNmbers>
</voiceFeatures>
<HuntGroup>
<huntGroupType>?</huntGroupType>
</HuntGroup>
</com:OCTService>
</soapenv:Body>
</soapenv:Envelope>
19087525238255
厕所
亚当
雷斯
NoSchedule
新界
0001
*
N
*
全日空航空公司
*
全日空航空公司
SR002
文学士
0
?
?
我无法使用CURL POST实现
这里重要的是SOAPAction,您可以在WSDL文档中使用它
$headers = array(
"Accept-Encoding: gzip,deflate",
"Content-Type: text",
"Cache-Control: no-cache",
"Username: yourusername",
"Password: password",
"SOAPAction: urn:OCTService",
"Content-length: ".strlen($xml_post_string),
); //SOAPAction: your op URL
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); // username and password - declared at the top of the doc
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
echo $response;
curl_close($ch);
// converting
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
// convertingc to XML
$parser = simplexml_load_string($response2);
$headers=数组(
“接受编码:gzip,deflate”,
“内容类型:文本”,
“缓存控制:无缓存”,
“用户名:你的用户名”,
“密码:密码”,
“SOAPAction:urn:OCTService”,
“内容长度:”.strlen($xml\u post\u string),
); //SOAPAction:您的操作URL
$ch=curl_init();
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($ch,CURLOPT_URL,$URL);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//curl_setopt($ch,CURLOPT_USERPWD,$soapUser.:“$soapPassword);//用户名和密码-在文档顶部声明
curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
curl_setopt($ch,CURLOPT_超时,10);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$xml_post_string);//SOAP请求
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
//转换
$response=curl\u exec($ch);
回音$应答;
卷曲关闭($ch);
//转换
$response1=str_replace(“,”,$response);
$response2=str_替换(“,”,$response1);
//将C转换为XML
$parser=simplexml\u load\u字符串($response2);