PHP SoapClient:操作不匹配
我正在尝试使用PHPSOAPClient扩展与外部SOAP服务器通信 这是我的代码:PHP SoapClient:操作不匹配,php,soap,soap-client,Php,Soap,Soap Client,我正在尝试使用PHPSOAPClient扩展与外部SOAP服务器通信 这是我的代码: $this->_client = new SoapClient(SOAP_TAGGING_URL, array( 'trace' => 1, 'soap_version' => SOAP_1_2, 'cache_wsdl' => WSDL_CACHE_NONE, 'exceptions' => true, 'uri' => SO
$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());
$this->\u client=新的SoapClient(SOAP\u标记\u URL,数组(
“跟踪”=>1,
“soap_版本”=>soap_1_2,
'cache\u wsdl'=>wsdl\u cache\u NONE,
“例外情况”=>true,
'uri'=>SOAP\u uri,
));
试试{
$actionHdr=array();
$actionHdr[]=新的SoapHeader(SOAP_TAGGING_URL,'Action','GetMessagesByTagsByGroup');
$this->_client->_setSoapHeaders($actionHdr);
$info=$this->_client->GetMessagesByTagsByGroup(
新的SoapParam($this->params['mPID','ParentMessageID'),
新的SoapParam($gid,'GroupId'),
新的SoapParam(请求令牌,'RequestToken'),
新的SoapParam(访问令牌,'AccessToken'),
新的SoapParam(访问令牌密钥,'AccessTokenSecret')
);
}catch(SoapFault$fault){
print(“\n
SOAP服务器返回以下错误:“..fault->faultcode.-”$fault->faultstring);
}
echo“\n
SOAP请求:”。htmlentities($this->_client->u getLastRequest());
echo“\n
SOAP响应:”。htmlentities($this->_client->uu getLastResponse());
这是我得到的答复(添加了格式):
SOAP服务器返回了以下错误:s:Sender消息“”上指定的SOAP操作与HTTP SOAP操作“”不匹配http://tempuri.org/ITagging/GetMessagesByTagsByGroup'.
SOAP请求:
GetMessagesByTagsByGroup
2178
odwedwo09i0jACqbbjsw6KnlCA=
OlVbHurPJrNrEFR54Y0hV9kI/TZs=
JS1KERF453Fluaxpl 892DY o=
SOAP响应:
http://www.w3.org/2005/08/addressing/fault
s:发件人
a:不匹配
消息“”上指定的SOAP操作与HTTP SOAP操作“”不匹配http://tempuri.org/ITagging/GetMessagesByTagsByGroup'.
a:行动
我想我在标题中添加了'Action'参数,但显然这不是放置它的地方。还是我做错了什么
不幸的是,我无法尝试NuSoap,因为我无法控制服务器
谢谢,
gm您将其作为SoapHeader传递,但实际上它是HTTP头 我发现这样做的方法是:设置$action参数
您可能需要扩展SoapClient类,以使用更少的代码行来完成此操作。这意味着不仅必须指定HTTP头SOAPAction:“http://www.bla.com:MyAction" 但您还需要在SOAP信封中指定标题: 请检查这些链接以获取一些参考:
您是否尝试过使用zend soap?SoapHeader和HTTP header之间的区别是什么?我扩展了SoapClient类以在执行uu doRequest之前转储操作名,并且已经在那里设置了操作。我已经尝试了很多方法和选项,但仍然会遇到相同的错误。我不确定WSClient类与SoapClient类有何不同。我已经在标题中设置了操作,但它似乎被忽略了。
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, '', does not match the HTTP SOAP Action, '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>