PHP中的SOAP头
我有一个复杂的SOAP头,它无法在web服务上传递安全性: 以下是所需的XML:PHP中的SOAP头,php,soap,Php,Soap,我有一个复杂的SOAP头,它无法在web服务上传递安全性: 以下是所需的XML: <soapenv:Header> <sec:Customer> <sec:Name>Name</sec:Name> </sec:Customer> <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-ws
<soapenv:Header>
<sec:Customer>
<sec:Name>Name</sec:Name>
</sec:Customer>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>User</Username>
<Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</Password>
</UsernameToken>
</Security>
</soapenv:Header>';
WsSecutiry头是特殊的,可能很难设置。它们没有声明为其他常见的Soap头 您的WsSecurity头非常基本,而当它包含密码摘要、nonce和其他时间戳信息时,它可能更复杂。可以使用项目轻松添加WsSecurity标头
您必须确定发送了什么(),并且如果不希望返回错误,您必须确保它与预期相符。如果仍然存在错误,应首先与web服务提供商联系。我在代码中没有看到任何错误,它与WS-interface匹配。您能否解释它为什么不工作或出现了什么错误?错误:xmlns:a=“>由于EndpointDispatcher上的ContractFilter不匹配,无法在接收方处理包含操作“”的消息。这可能是因为契约不匹配(发送方和接收方之间的操作不匹配)或者发送方和接收方之间的绑定/安全不匹配。请检查发送方和接收方是否具有相同的契约和相同的绑定(包括安全要求,例如消息、传输、无)。是否尝试转储SOAP请求以查看SOAP客户端``向web服务发送的真正内容?
var\u dump($client->\uuu getLastRequestHeaders());
和var\u dump($client->\uu getLastRequest());
由于缺少WSSecurity标头,显然无法工作
$client = new SoapClient($wsdl, array( 'trace' => 1,'exceptions' => 1));
$cust = array('Name' => "Name");
$token = array('UsernameToken' => array('Username' => "User",'Password' => "Password" ));
$headers = array();
$headers[] = new SoapHeader($ns1,'Customer',$cust);
$headers[] = new SoapHeader($ns2,'Security',$token);
$client->__setSoapHeaders($headers);