PHP SoapClient:动作不匹配
发布时间:2020-12-13 16:23:04 所属栏目:PHP教程 来源:网络整理
导读:我试图使用 PHP SoapClient扩展与外部SOAP服务器进行通信. 这是我的代码: $this-_client = new SoapClient(SOAP_TAGGING_URL,array( 'trace' = 1,'soap_version' = SOAP_1_2,'cache_wsdl' = WSDL_CACHE_NONE,'exceptions' = true,'uri' = SOAP_URI,)); try
我试图使用
PHP SoapClient扩展与外部SOAP服务器进行通信.
这是我的代码: $this->_client = new SoapClient(SOAP_TAGGING_URL,array( 'trace' => 1,'soap_version' => SOAP_1_2,'cache_wsdl' => WSDL_CACHE_NONE,'exceptions' => true,'uri' => SOAP_URI,)); try { $actionHdr = array(); $actionHdr[] = new SoapHeader(SOAP_TAGGING_URL,'Action','GetMessagesByTagsByGroup'); $this->_client->__setSoapHeaders($actionHdr); $info = $this->_client->GetMessagesByTagsByGroup( new SoapParam($this->params['mPID'],'ParentMessageID'),new SoapParam($gid,'GroupId'),new SoapParam(REQUEST_TOKEN,'RequestToken'),new SoapParam(ACCESS_TOKEN,'AccessToken'),new SoapParam(ACCESS_TOKEN_SECRET,'AccessTokenSecret') ); } catch (SoapFault $fault) { print("n<br/>SOAP server returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring); } echo "n<br/>SOAP request: ". htmlentities($this->_client->__getLastRequest()); echo "n<br/>SOAP response: ". htmlentities($this->_client->__getLastResponse()); 这是我得到的响应(格式化添加): SOAP server returned the following ERROR: s:Sender-The SOAP action specified on the message,'',does not match the HTTP SOAP Action,'http://tempuri.org/ITagging/GetMessagesByTagsByGroup'. SOAP request: <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/" xmlns:ns2="https://mywebserver.com/myWSDL.svc/ws?wsdl"> <env:Header> <ns2:Action>GetMessagesByTagsByGroup</ns2:Action> </env:Header> <env:Body> <ns1:GetMessagesByTagsByGroup/> <GroupId>2178</GroupId> <RequestToken>odwedwo09i0jACqbbjsw6KnlCA=</RequestToken> <AccessToken>OlVbHurPJrNrEFR54Y0hV9kI/TZs=</AccessToken> <AccessTokenSecret>js1kerfe453FLuaXpL 892DY o=</AccessTokenSecret> </env:Body> </env:Envelope> SOAP response: <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/fault</a:Action> </s:Header> <s:Body> <s:Fault> <s:Code> <s:Value>s:Sender</s:Value> <s:Subcode> <s:Value>a:ActionMismatch</s:Value> </s:Subcode> </s:Code> <s:Reason> <s:Text xml:lang="en-US">The SOAP action specified on the message,'http://tempuri.org/ITagging/GetMessagesByTagsByGroup'. </s:Text> </s:Reason> <s:Detail> <a:ProblemHeaderQName>a:Action</a:ProblemHeaderQName> </s:Detail> </s:Fault> </s:Body> </s:Envelope> 我以为我在标题中添加了’Action’参数,但显然不是放置它的地方.或者我做错了什么? 不幸的是我无法尝试NuSoap,因为我无法控制服务器. 谢谢, 克 解决方法
这意味着您不仅必须指定HTTP标头SOAPAction:“http://www.bla.com:MyAction”
但您还需要在SOAP Envelope中指定标头: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |