doushan15559 2011-02-23 16:10
浏览 65

PHP SoapClient生成不同的格式化SOAP请求

So I am tring to connect to a third party service and having some issues with it in PHP. When I try the service request in WebService Studio it works fine and the sent request looks like this:

<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <createUser xmlns="http://ws.example.com">
            <arg0 xmlns="">test@test.com</arg0>
            <arg1 xmlns="">123</arg1>
            <arg2 xmlns="">1234</arg2>
            <arg3 xmlns="">1234567890abcdef</arg3>
            <arg4 xmlns="">test</arg4>
            <arg5 xmlns="">user</arg5>
            <arg6 xmlns="">02472</arg6>
            <arg7 xmlns="">test@test.com</arg7>
            <arg8 xmlns="">A</arg8>
            <arg9 xmlns="">0</arg9>
            <arg10 xmlns="">true</arg10>
        </createUser>
    </soap:Body>
</soap:Envelope>

Now when I try to call the service from PHP with the following command:

$this->web_service->createAccount('test@test.com', 123, 1234, '1234567890abcdef', 'test', 'user', '12345', 'test@test.com', 'A', 0, true)

and debugging the request, I get this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.example.com">
    <SOAP-ENV:Body>
        <ns1:createUser/>
        <param1>123</param1>
        <param2>1234</param2>
        <param3>1234567890abdcef</param3>
        <param4>test</param4>
        <param5>user</param5>
        <param6>12345</param6>
        <param7>test@test.com</param7>
        <param8>A</param8>
        <param9>0</param9>
        <param10>true</param10>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

A few things jump out at me right away with the request generated by SoapClient in PHP. The first thing is that the first parameter (the first time I pass test@test.com) is not being passed in param1, the second parameter is. The next thing is the the request to createUser is a self closing tag not including the parameters being pass. Then obviously the whole structure is a little different with the tag being used.

I have tried using an array (which doesn't even go to the point of throwing the request), wrapping the params in SoapParam, using __call(), and using __soapCall() but none of those fix this issue.

Anyone know what might fix this issue so the request generated by SoapClient in PHP matches the one generated by WebService Studio short of manually generate the soap request by hand?

  • 写回答

2条回答 默认 最新

  • doudunyi3796 2011-02-23 20:43
    关注

    I think you may be better served using an array with parameter names for indices

    $this->webService->createAccount(array('arg0'=>'test@test.com')...);
    

    or use the __soapCall function

    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗