1

PHP SOAP 呼び出しの本文の設定に問題があります。正しい形式で取得する方法がわからないだけで、私は近いと思います。

ここに私がこれまでPHPで持っていたものがあります

    $client = new SoapClient('http://url');
    $username='username';
    $password='password';

    $headers='
        '.$username.'
        '.$password.'
    ';

    $securityTags = new SoapVar($headers, XSD_ANYXML);

    $header=new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security",$securityTags,true);

    $client->__setSoapHeaders(array($header));

    //HOW DO I SET THE BODY????
    $params = array('deal'=>'PT10M', 'StoreIds'=>64);
    return $client->__soapCall("PullDeals", array('searchCriteria'=>$params));

以下は、リクエストがどのように見えるかです

<soapenv:Envelope xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:deal="http://url.com" xmlns:ns="http://url" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header>
      <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
         <wsse:UsernameToken wsu:Id="UsernameToken-145" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>YOUR_USERNAME</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">YOUR_PASSWORD</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">JQT6P7Zd3COZerXkREww2g==</wsse:Nonce>
            <wsu:Created>2013-11-19T22:18:54.122Z</wsu:Created>
         </wsse:UsernameToken>
      </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
      <ns:PullDeals>
         <ns:searchCriteria>
            <deal:MaxElapsedSinceUpdate>PT10M</deal:MaxElapsedSinceUpdate>           
            <deal:StoreIds><arr:long>64</arr:long></deal:StoreIds>
         </ns:searchCriteria>
      </ns:PullDeals>
   </soapenv:Body>
</soapenv:Envelope>
4

1 に答える 1

1

リクエストを、リクエストがどのように見えるべきかを比較するには'trace' => true、SOAP クライアントに追加します。

$client = new SoapClient("my.wsdl", array('trace' => true));

を使用echo $client->__getLastRequest();して XML を吐き出します。

私は通常、クロムのインスペクターを使用してページ上で表示し、適切にインデントされていることを確認します。

呼び出しがどのように形成されているかを確認した後、それに応じて呼び出しを再フォーマットできます。

XML をハードコーディングできない場合。

于 2013-11-25T14:23:04.023 に答える