我无法将标头传递给WSDL for credencials:
这是代码:
$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'=> 'test@test.com'));
var_dump($res);
我收到以下错误:
致命错误:未捕获的SoapFault异常:[soap:客户端]请 提供安全标头...
这是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>
答案 0 :(得分:2)
我已经审核了您的SOAP请求,如果您完全比较,您可以看到两个问题:
如果我尝试以下操作,那么我会收到一条错误消息,告知我的凭据无效,这是有道理的,因为我只填写了一些内容。我不会再得到安全头故障了。
$soapClient = new SoapClient("https://www.em-sender.com/ws/InwiseWebServices.asmx?WSDL", array('trace' => true));
$header = new SoapVar(array('username' => 'user', 'pass' => 'password'), SOAP_ENC_OBJECT);
$soapClient->__setSoapHeaders(new SoapHeader("http://www.inwise.com/schemas",'SecHeader',$header));
try {
$res = $soapClient->Recipients_checkUnsubscribed('test@test.com');
var_dump($res);
} catch(SoapFault $fault) {
var_dump($soapClient->__getLastRequest());
var_dump($fault->getMessage());
}