SOAP 请求中的 ns1 和 tem 不匹配会影响请求吗?

Does mismatching of ns1 and tem in a SOAP Request affect the request?

我不知道怎么写,但我应该发送一个格式如下的 SOAP 请求:

<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' => '60123456789',
        '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" 作为客户端期望的吗?请帮忙

不应该。命名空间前缀仅引用实际命名空间(xmlns:* 命名空间定义节点中的值)。前缀对于元素节点是可选的,并且可以在每个元素节点上更改。所以tem:RequestTopup实际上应该读作{http://tempuri.org/}RequestTopup。这里有 3 个示例,它们都解析为名称空间 http://tempuri.org/ 中的节点,本地名称为 RequestTopup

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

但是,我看到了比我想要的更多的错误实现。他们通常依赖特定的命名空间前缀而忽略实际的命名空间。