2011-12-21 8 views
4

PHP SoapClient拡張を使用して外部SOAPサーバーと通信しようとしています。PHP SoapClient:アクションの不一致

これは私のコードです:

$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, '', 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> 

私は、ヘッダーで「アクション」パラメータを追加したと思ったが、明確にすることをそれを置く場所ではありません。それとも別のことをやっているのですか?

残念ながら、サーバーを制御できないため、残念ながらNuSoapを試すことはできません。

はあなたがSoapHeaderはとしてそれを渡している

、GM

+0

あなたはゼンド石鹸を使いこなしましたか? –

答えて

1

をいただきありがとうございますが、実際には、HTTPヘッダーです。

$ actionパラメータを設定してhttp://lt.php.net/manual/en/soapclient.dorequest.phpとすると見つかりました。

SoapClientクラスを拡張して、コードの行数を減らす必要があるでしょう。

+1

SoapHeaderとHTTPヘッダーの違いは何ですか? SoapClientクラスを拡張して__doRequestを実行する前にアクション名をダンプし、そのアクションは既にそこに設定されています。 私は多くの方法とオプションを試しましたが、私はまだ同じエラーが発生します。 –

2

それはあなたがHTTPヘッダーのSOAPActionを指定しなければならないだけでなく、ことを意味意味:「http://www.bla.com:MyAction」

をいますが、SOAPエンベロープでもヘッダーを指定する必要があります。 チェックいくつかの参考のためのこれらのリンク: SOAP ACTION

+1

WSClientクラスがSoapClientクラスとどのように違うかわかりません。私はヘッダーにアクションを設定しましたが、無視されるようです。 –