使用 PHP 向 Soap Server 提交数据
我无法将标头传递给 WSDL 以获取凭证:
这是代码:
$soapClient = new SoapClient("https://www.em-sender.com/ws/InwiseWebServices.asmx?WSDL");
$header = array('user'=>'user1','pass'=>'pass1');
$soapClient->__setSoapHeaders(new SoapHeader("https://www.em-sender.com/ws/InwiseWebServices.asmx?WSDL",'SecHeader',$header));
$res = $soapClient->__call("Recipients_checkUnsubscribed", array('email'=> '[email protected]'));
var_dump($res);
我收到以下错误:
致命错误:未捕获 SoapFault 异常:[soap:Client] 请 提供安全标头...
这是 WSDL 描述: https:// www.em-sender.com/ws/InwiseWebServices.asmx?op=Recipients_checkUnsubscribed
或参见此处:
POST /ws/InwiseWebServices.asmx HTTP/1.1
Host: www.em-sender.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<SecHeader xmlns="http://www.inwise.com/schemas">
<username>string</username>
<pass>string</pass>
</SecHeader>
<AuthIdentifier xmlns="http://www.inwise.com/schemas">
<identifier>string</identifier>
</AuthIdentifier>
</soap12:Header>
<soap12:Body>
<Recipients_checkUnsubscribed xmlns="http://www.inwise.com/schemas">
<email>string</email>
</Recipients_checkUnsubscribed>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Recipients_checkUnsubscribedResponse xmlns="http://www.inwise.com/schemas">
<Recipients_checkUnsubscribedResult>boolean</Recipients_checkUnsubscribedResult>
</Recipients_checkUnsubscribedResponse>
</soap12:Body>
</soap12:Envelope>
编辑
这是发送的字符串:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.inwise.com/schemas" xmlns:ns2="https://www.em-sender.com/ws/InwiseWebServices.asmx?WSDL">
<SOAP-ENV:Header>
<ns2:SecHeader>
<item>
<key>user</key>
<value>user1</value>
</item>
<item>
<key>pass</key>
<value>pass1</value>
</item>
</ns2:SecHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:Recipients_checkUnsubscribed/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am unable to pass the header to the WSDL for credencials:
this is the code:
$soapClient = new SoapClient("https://www.em-sender.com/ws/InwiseWebServices.asmx?WSDL");
$header = array('user'=>'user1','pass'=>'pass1');
$soapClient->__setSoapHeaders(new SoapHeader("https://www.em-sender.com/ws/InwiseWebServices.asmx?WSDL",'SecHeader',$header));
$res = $soapClient->__call("Recipients_checkUnsubscribed", array('email'=> '[email protected]'));
var_dump($res);
I am getting the following error:
Fatal error: Uncaught SoapFault exception: [soap:Client] Please
provide security header in...
this is the WSDL description: https://www.em-sender.com/ws/InwiseWebServices.asmx?op=Recipients_checkUnsubscribed
or see here:
POST /ws/InwiseWebServices.asmx HTTP/1.1
Host: www.em-sender.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<SecHeader xmlns="http://www.inwise.com/schemas">
<username>string</username>
<pass>string</pass>
</SecHeader>
<AuthIdentifier xmlns="http://www.inwise.com/schemas">
<identifier>string</identifier>
</AuthIdentifier>
</soap12:Header>
<soap12:Body>
<Recipients_checkUnsubscribed xmlns="http://www.inwise.com/schemas">
<email>string</email>
</Recipients_checkUnsubscribed>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Recipients_checkUnsubscribedResponse xmlns="http://www.inwise.com/schemas">
<Recipients_checkUnsubscribedResult>boolean</Recipients_checkUnsubscribedResult>
</Recipients_checkUnsubscribedResponse>
</soap12:Body>
</soap12:Envelope>
Edit
This is the sent string:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.inwise.com/schemas" xmlns:ns2="https://www.em-sender.com/ws/InwiseWebServices.asmx?WSDL">
<SOAP-ENV:Header>
<ns2:SecHeader>
<item>
<key>user</key>
<value>user1</value>
</item>
<item>
<key>pass</key>
<value>pass1</value>
</item>
</ns2:SecHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:Recipients_checkUnsubscribed/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经审查了您的 SOAP 请求,如果您进行精确比较,您会发现两个问题:
如果我尝试以下操作,则会收到一条错误消息,告诉我的凭据无效,这是有道理的,因为我刚刚填写了一些内容。我不会再遇到安全标头错误了。
I have reviewed your SOAP request, and if you exactly compare you can see two problems:
If I try the following then I get a error message telling my credentials are invalid which makes sense because I just filled in something. I won't get the security header fault anymore.