卷曲错误"发送结束前的HTTP错误,停止发送"什么时候发送SOAP请求php

时间:2015-09-09 16:42:38

标签: php web-services iis curl soap

所以我需要与SOAP API进行交互,我通过curl使用以下函数发送我的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>

传递了SOAP消息

<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>

回显&#39; out out给出500错误

  

&LT; HTTP / 1.1 100继续&lt;通过:1.1 FERNTMG01&lt; HTTP / 1.1 500内部   服务器错误&lt;连接:Keep-Alive&lt;内容长度:648 <日期:   2015年9月9日星期三16:38:58 GMT&lt; Content-Type:application / soap + xml;   字符集= utf-8的   *服务器Microsoft-IIS / 7.5未列入黑名单&lt;服务器:Microsoft-IIS / 7.5&lt; X-Clacks-Overhead:GNU Terry Pratchett   *发送结束前的HTTP错误,停止发送&lt;   *关闭连接0 500

我从上周写的一个不同的SOAP服务中删除了这个函数的基础知识,这个服务运行正常,所以我对这个问题有点难过

编辑: 刚刚在mac&#39; Restinsoap&#39;我得到以下回复仍然是500

{{1}}

但是如果我在Windows机器上执行wcfstorm请求很好

1 个答案:

答案 0 :(得分:0)

SOAP服务期望有效负载的标头部分中的身份验证详细信息。

尝试在RestInSoap客户端的有效负载的标头部分(<x:Header>?</x:Header>)中添加此WSS令牌。

更改用户名&amp;密码根据需要。

<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>