douganbi7686 2010-10-22 05:44
浏览 108

为什么PHP的SoapClient为标题创建了一个与主体不同的命名空间?

I'm trying to communicate with the eWay server and had everything working until we ended up needing to switch to a different API. The problem is that SoapClient is creating a different namespace for the header (that includes the authentication) then from the body, which, obviously, doesn't get me any results. Instead, I get eWay's servers saying it must have the authentication information.

Here's my code:

   $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>
";
    }

As you can see, I've tried it with and without using a SoapVar for the header, all with no luck.

Here's the XML request that is being created:

<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>
  • 写回答

1条回答 默认 最新

  • dooid3005 2011-04-11 07:10
    关注

    This may be an obvious question, but did you try specifying the typename and type namespace in the SoapVar() call?

    评论

报告相同问题?

悬赏问题

  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大