2017-02-15 5 views
3

私はこれを配置する方法を知りませんが、私は次の書式でSOAPリクエストを送信することになった。SOAPリクエスト内のns1とtemの不一致がリクエストに影響しますか?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:tem="http://tempuri.org/"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <tem:RequestTopup> 
      <tem:sClientUserName>?</tem:sClientUserName> 
      <tem:sClientPassword>?</tem:sClientPassword> 
      <tem:sClientTxID>?</tem:sClientTxID> 
      <tem:sProductID>?</tem:sProductID> 
      <tem:dProductPrice>?</tem:dProductPrice> 
      <tem:sCustomerAccountNumber>?</tem:sCustomerAccountNumber> 
      <tem:sCustomerMobileNumber>?</tem:sCustomerMobileNumber> 
      <tem:sEncKey>?</tem:sEncKey> 
     </tem:RequestTopup> 
    </soapenv:Body> 
</soapenv:Envelope> 

私のPHPコードは以下のようなものだった:

$opts = array(
    'ssl' => array('ciphers' => 'RC4-SHA', 'verify_peer' => false, 'verify_peer_name' => false) 
); 

$params = array(
    'encoding' => 'UTF-8', 
    'verifypeer' => false, 
    'verifyhost' => false, 
    'trace' => 1, 'exceptions' => 1, 
    "connection_timeout" => 180, 
    'stream_context' => stream_context_create($opts) 
); 



$client = new SoapClient("http://xmpl/connect.asmx?WSDL", $params);  

    $txn_id = "2017021234567"; 

$result = $client->RequestTopup(
    array(
     'sClientUserName' => '6', 
     'sClientPassword' => '123456789', 
     'sProductID' => '1', 
     'dProductPrice' => '10', 
     'sClientTxID' => $txn_id, 
     'sCustomerAccountNumber' => '60166527234', 
     'sCustomerMobileNumber' => '60166527234', 
     'sEncKey' => 'sample_enc', 
    ) 
); 

echo $client->__getLastRequest(); 

さて、問題正しい形式でXMLを生成しますが、"tem""ns1"に置き換えます。申し訳ありませんが、私は両者の違いがわからず、グーグルはあまり役に立たなかった。

"ns1"でxmlをリクエストすると、これは何か違いがありますか?クライアント側が期待しているように "tem"に変更する必要がありますか?助けてください。

答えて

1

そうしてはいけません。名前空間接頭辞は、実際の名前空間(名前空間定義ノードxmlns:*の値)のみを参照します。接頭辞は要素ノードではオプションであり、各要素ノードで変更できます。従ってtem:RequestTopupは実際には{http://tempuri.org/}RequestTopupと読み替えてください。ここではしかし、私は多くの障害のある実装を見てきたローカル名と名前空間http://tempuri.org/内のすべてのノードに解決さ3例RequestTopup

  • <tem:RequestTopup xmlns:tem="http://tempuri.org/"/>
  • <ns1:RequestTopup xmlns:ns1="http://tempuri.org/"/>
  • <RequestTopup xmlns="http://tempuri.org/"/>

ですそれから私は好きです。彼らはしばしば特定の名前空間接頭辞に頼って、実際の名前空間を無視します。

+0

ありがとうございました。あなたはすべてをクリアにしました。しかし、ns1をtemに置き換える方法はありますか? –

+0

XMLノードを再作成する必要があります。 FluentDOMにオプティマイザを実装しました。これを使用して、これを行うことができます:https://github.com/FluentDOM/FluentDOM/blob/master/examples/Transformer/Namespaces/optimize.php – ThW

関連する問題