2011-12-21 4 views
4

외부 SOAP 서버와 통신하기 위해 PHP SoapClient 확장을 사용하려고합니다.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을 시도 할 수 없습니다.

, 감사합니다

GM

+0

zend soap을 사용해 보셨습니까? –

답변

1

당신의 SOAPHeader로 전달하고 있지만 실제로는 HTTP 헤더입니다.

$ action 매개 변수를 설정하여 http://lt.php.net/manual/en/soapclient.dorequest.php을 찾았습니다.

코드 줄을 줄이기 위해 SoapClient 클래스를 확장해야 할 수도 있습니다.

+1

SoapHeader와 HTTP 헤더의 차이점은 무엇입니까? __doRequest를 수행하기 전에 액션 이름을 덤프하도록 SoapClient 클래스를 확장했으며 액션이 이미 설정되어 있습니다. 여러 가지 방법과 옵션을 시도했지만 동일한 오류가 발생합니다. –

2

그것은뿐만 아니라 당신이 HTTP 헤더의 SOAPAction 지정해야합니다 것을 의미 의미 : "http://www.bla.com:MyAction"

을하지만 당신은 SOAP 봉투도 헤더를 지정해야합니다 확인 일부 참조를위한 이러한 링크 : SOAP ACTION

+1

WSClient 클래스가 SoapClient 클래스와 어떻게 다른지 잘 모르겠습니다. 헤더에 액션을 설정했지만 무시되는 것 같습니다. –

관련 문제