使用Soapclient查看报头Soap请求


Seeting Headers Soap Request with Soapclient

我需要一些帮助与soapclient制作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://tempuri.org/IToken/...</a:Action>
<a:MessageID>urn:uuid:...</a:MessageID>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://...</a:To>
</s:Header>

我试过用curl做同样的请求,它是工作的,但是现在我需要用SoapClient做它,我不能理解为什么我不能用SoapClient做它。我得到的错误总是这个Uncaught SoapFault exception: [s:Sender]消息上指定的SOAP动作",不匹配HTTP SOAP动作错误请求。我已经尝试了很多方法,我已经坚持了两天。

您可以将SoapClient扩展到自己的类中。然后像下面这样重写__doRequest:

public function __doRequest($request , $location , $action , $version, $one_way = 0 )
{
    $request = <mix your header into the $request somehow>;
    return parent::__doRequest($request, $location, $action , $version, $one_way);
}