Php 卷曲误差;发送结束前HTTP错误,停止发送“;在发送SOAP请求时
因此,我需要与SOAP API交互,我使用以下函数通过curl发送SOAP消息Php 卷曲误差;发送结束前HTTP错误,停止发送“;在发送SOAP请求时,php,web-services,iis,curl,soap,Php,Web Services,Iis,Curl,Soap,因此,我需要与SOAP API交互,我使用以下函数通过curl发送SOAP消息 /** * @param $soap_msg * @return int */ function send($soap_msg) { //init curl $ch = curl_init(); //set some debug curl_setopt($ch, CURLOPT_RETURNTRA
/**
* @param $soap_msg
* @return int
*/
function send($soap_msg)
{
//init curl
$ch = curl_init();
//set some debug
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
//set request method
curl_setopt($ch, CURLOPT_POST, true);
//set some other options
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, true);
curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
//set auth info
$username = 'user';
$password = '%PASS$';
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
//build header array
$headers = array();
$headers[] = 'Content-Type: application/soap+xml; charset=utf-8';
$headers[] = 'Accept-Encoding: gzip, deflate';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Expect: 100-continue';
$headers[] = 'SOAPAction: http://ACTION/URL';
$headers[] = "Content-length: ".strlen($soap_msg);
//set headers
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//set payload
curl_setopt($ch, CURLOPT_POSTFIELDS, $soap_msg);
//set soap resource
curl_setopt($ch, CURLOPT_URL, 'https://SOME.URL.co.uk/SERVICE.svc/detail');
//execute request
curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $info;
}
echo send($soap_msg);
?>
传递的SOAP消息
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://my.action/endpoint/GetJob</a:Action>
<a:MessageID>urn:uuid:b7747707-97cc-4edf-9cb0-b8dd40f45509</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://my.webservice.co.uk/Appt/AppointWS/service.svc/detail</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<u:Timestamp u:Id="_0">
<u:Created>2015-09-08T19:52:16.065Z</u:Created>
<u:Expires>2015-09-08T19:57:16.065Z</u:Expires>
</u:Timestamp>
<o:UsernameToken u:Id="uuid-2c7e3d75-b18d-480a-979e-57e6a042e9f2-2">
<o:Username>user</o:Username>
<o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">%pass$</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<GetJob xmlns="http://tempuri.org/">
<jobEntryId>630422258</jobEntryId>
<jobNo1>3874527</jobNo1>
<contractId>220000</contractId>
</GetJob>
</s:Body>
</s:Envelope>
http://my.action/endpoint/GetJob
urn:uuid:b7747707-97cc-4edf-9cb0-b8dd40f45509
http://www.w3.org/2005/08/addressing/anonymous
https://my.webservice.co.uk/Appt/AppointWS/service.svc/detail
2015-09-08T19:52:16.065Z
2015-09-08T19:57:16.065Z
用户
%通过$
630422258
3874527
220000
发出的回声有500个错误
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
<a:RelatesTo>urn:uuid:588e5592-c60a-4c2d-b643-c6af9c4772f5</a:RelatesTo>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-GB">An error occurred when verifying security for the message.</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>
http://www.w3.org/2005/08/addressing/soap/fault
urn:uuid:588e5592-c60a-4c2d-b643-c6af9c4772f5
s:发件人
a:无效安全
验证邮件的安全性时出错。
但是,如果我在windows机器上的wcfstorm中执行请求,那么请求就可以了SOAP服务在有效负载的头部分中需要身份验证详细信息 尝试将此WSS令牌添加到RestInSoap客户端中有效负载的头部分(
?
)
根据需要更改用户名和密码
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>asd</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">asd</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">8lrPhyvoNtE8Gp0wOJMcOw==</wsse:Nonce>
<wsu:Created>2015-09-10T05:17:40.296Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
自闭症
自闭症
8lrPhyvoNtE8Gp0wOJMcOw==
2015-09-10T05:17:40.296Z
SOAP服务期望在有效负载的头部分中包含身份验证详细信息
尝试将此WSS令牌添加到RestInSoap客户端中有效负载的头部分(?
)
根据需要更改用户名和密码
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>asd</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">asd</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">8lrPhyvoNtE8Gp0wOJMcOw==</wsse:Nonce>
<wsu:Created>2015-09-10T05:17:40.296Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
自闭症
自闭症
8lrPhyvoNtE8Gp0wOJMcOw==
2015-09-10T05:17:40.296Z
是的,我没有包括我发送的SOAP消息,但我们发送了一条包含这些详细信息的完全格式化的SOAP消息。如前所述,我可以从基于windows的SOAP客户端发送,但当php im出现错误时,我在原始问题中添加了发送的信封是的,我没有包括我发送的SOAP消息,但我们发送了一个包含这些详细信息的完全格式化的SOAP消息。如前所述,我可以从基于windows的SOAP客户端发送,但当php im出现错误时,我在原始问题中添加了发送的信封