我有这个代码,我想用它来发送SOAP请求,但结果是什么都没有成功,也没有错误代码或消息。那么如何使用以下代码将正确的SOAP请求发送到正确的URL
Service Endpoint URL
https://pod.test.at.serviceDomain.com
Web Service Definition Language (WSDL) URL
https://pod.test.at.serviceDomain.com/pod/services/PodService?wsdl
$soapUrl = "https://pod.test.at.serviceDomain.com/pod/services/PodService?wsdl"; // I've tried the other url but the same result
$soapUser = "testuser"; // username
$soapPassword = "testpass"; // password
$xml_post_string = "<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name='PodService' targetNamespace='http://www.serviceDomain.com/enterprise/distribution/podService/v1' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://www.serviceDomain.com/enterprise/distribution/podService/v1'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<wsdl:documentation>Version: 1.0.0</wsdl:documentation>
<wsdl:types>
<xsd:schema targetNamespace='http://www.serviceDomain.com/enterprise/distribution/podService/v1'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://www.serviceDomain.com/enterprise/distribution/podService/v1'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<xsd:element name='executeOrder'>
<xsd:complexType>
<xsd:sequence>
<xsd:element name='username' type='testuser'>
</xsd:element>
<xsd:element name='password' type='testpass'>
</xsd:element>
<xsd:element minOccurs='0' name='retailerId' type='tns:'>
</xsd:element>
<xsd:element name='orderId' type='tns:123456'>
</xsd:element>
<xsd:element name='faceValue' type='tns:50.00'>
</xsd:element>
<xsd:element name='productId' type='tns:000666'>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>";
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: \"run\"",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
[update: changed to:]
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
echo $response;
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$parser = simplexml_load_string($response2);
echo $parser['resultCode'];
curl_close($ch);