Creating a SOAP call using PHP with an XML body(使用 PHP 和 XML 主体创建 SOAP 调用)
问题描述
我正在尝试使用 PHP 调用 SOAP 方法.
I'm trying to call a SOAP method using PHP.
这是我得到的代码:
这是它创建的请求:
这是我希望请求的样子:
推荐答案
有几种方法可以解决这个问题.最简单的,几乎是您想要的:
There are a couple of ways to solve this. The least hackiest and almost what you want:
这会为您提供以下 XML:
This gets you the following XML:
这几乎正是您想要的,除了方法名称上的命名空间.我不知道这是否有问题.如果是这样,您可以进一步破解它.您可以手动将 <Echo>
标记放入 XML 字符串中,并通过添加 'style' => 让 SoapClient 不设置方法.SOAP_DOCUMENT,
到 options 数组如下:
That is almost exactly what you want, except for the namespace on the method name. I don't know if this is a problem. If so, you can hack it even further. You could put the <Echo>
tag in the XML string by hand and have the SoapClient not set the method by adding 'style' => SOAP_DOCUMENT,
to the options array like this:
这会产生以下请求 XML:
This results in the following request XML:
最后,如果你想玩转 SoapVar 和 SoapParam 对象,你可以在 PHP 手册的这个注释中找到一个很好的参考:http://www.php.net/manual/en/soapvar.soapvar.php#104065.如果你成功了,请告诉我,我失败得很惨.
Finally, if you want to play around with SoapVar and SoapParam objects, you can find a good reference in this comment in the PHP manual: http://www.php.net/manual/en/soapvar.soapvar.php#104065. If you get that to work, please let me know, I failed miserably.
这篇关于使用 PHP 和 XML 主体创建 SOAP 调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!