2

我正在尝试与 eWay 服务器通信,并且一切正常,直到我们最终需要切换到不同的 API。问题是 SoapClient 正在为标头(包括身份验证)然后从正文创建不同的命名空间,这显然不会给我任何结果。相反,我得到 eWay 的服务器说它必须具有身份验证信息。

这是我的代码:

   $client = new SoapClient($url.'?WSDL', array('trace'=>TRUE));

   // Set our SOAP Headers for authentication
    $header_body = array(
        'eWAYCustomerID'    => $gateway['customer_id'],
        'Username'          => $gateway['username'],
        'Password'          => $gateway['password']
    );

    $header_var = new SoapVar($header_body, SOAP_ENC_OBJECT);       
    $header = new SOAPHeader('http://www.eway.com.au/gateway/managedpayment', 'eWAYHeader', $header_body);
    //$client->__setSoapHeaders($header);

    try {
        $response = $client->__soapCall($action, $xml, null, $header);
    } catch (SoapFault $e)
    {
        echo 'SOAP Fault: '. $e->getMessage()."<br>\n";
    }

如您所见,我已经尝试过使用和不使用 SoapVar 作为标题,但都没有运气。

这是正在创建的 XML 请求:

<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.eway.com.au/gateway/managedpayment" xmlns:ns2="http://www.eway.com.au/gateway/managedpayment">
<soap-env:header>
    <ns2:ewayheader>
        <ewaycustomerid>87654321</ewaycustomerid>
        <username>test@eway.com.au</username>
        <password>test123</password>
    </ns2:ewayheader>
</soap-env:header>
<soap-env:body>
    <ns1:createcustomer>...</ns1:createcustomer>
4

1 回答 1

0

这可能是一个显而易见的问题,但您是否尝试在 SoapVar() 调用中指定类型名和类型命名空间?

于 2011-04-11T07:10:47.630 回答