PHP SoapClient 调用响应缺少部分答案
我对下面的脚本有问题。它只是不想发回任何响应。
脚本:
<?php
require_once('nusoap.php');
$c = new soapclient('http://hidden.com/api/soap_affiliate.php?wsdl');
$result = $c->__call('optionalInfo', array('client'=> 'hidden','add_code' => 'hidden','password'=> 'hidden' ,
'start_date' => '2011-03-15','end_date' => '2011-03-24' , 'program_id' => '000' , 'opt_info' => 'x' ));
echo $result;
?>
返回的内容如下:
<?xml version="1.0" encoding="utf-8"?>
<item>
</item>
它应该从我的客户返回一些详细信息,尽管它甚至不显示空字段。
更多细节应该是这样的:
<?xml version="1.0" encoding="utf-8"?>
<item>
<dailystats>
<date>2011-03-18</date>
<impressions>17</impressions>
<clicks>1</clicks>
<leads>1</leads>
<num_sales>0</num_sales>
<sales> 0.00</sales>
<sub_sales> 0.00</sub_sales>
<commission> 1.10</commission>
<click_thru_ratio>5.88%</click_thru_ratio>
</dailystats>
</item>
我已经尝试了我能做的任何事情(我对肥皂有多少了解),但它不会返回任何其他内容。 那么有人可以帮我解决这个脚本吗?
所需的Web服务如下,
- <message name="optionalInfoRequest">
<part name="client" type="xsd:string" />
<part name="add_code" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="start_date" type="xsd:string" />
<part name="end_date" type="xsd:string" />
<part name="program_id" type="xsd:int" />
<part name="opt_info" type="xsd:string" />
</message>
- <message name="optionalInfoResponse">
<part name="return" type="xsd:string" />
</message>
整个WSDL可以在这里找到WSDL服务
编辑:
谢谢wrikken,它把我推向了正确的方向。我对脚本进行了一些编辑:现在有一个“opt_info”标签。我必须在这里输入电子邮件地址和日期,以便它也返回它们。有人可以帮我做这个吗?
I have a problem with the script below. It just doesn't want to post back any response.
The script:
<?php
require_once('nusoap.php');
$c = new soapclient('http://hidden.com/api/soap_affiliate.php?wsdl');
$result = $c->__call('optionalInfo', array('client'=> 'hidden','add_code' => 'hidden','password'=> 'hidden' ,
'start_date' => '2011-03-15','end_date' => '2011-03-24' , 'program_id' => '000' , 'opt_info' => 'x' ));
echo $result;
?>
What gets returned is the following:
<?xml version="1.0" encoding="utf-8"?>
<item>
</item>
it should return some details from my clients although it doesn't even show empty fields.
What it should look like with some more details is this:
<?xml version="1.0" encoding="utf-8"?>
<item>
<dailystats>
<date>2011-03-18</date>
<impressions>17</impressions>
<clicks>1</clicks>
<leads>1</leads>
<num_sales>0</num_sales>
<sales> 0.00</sales>
<sub_sales> 0.00</sub_sales>
<commission> 1.10</commission>
<click_thru_ratio>5.88%</click_thru_ratio>
</dailystats>
</item>
I have tried anything I can (for how much I know soap ) but it wont return anything else.
So can someone help me out with this script?
The needed webservice is below,
- <message name="optionalInfoRequest">
<part name="client" type="xsd:string" />
<part name="add_code" type="xsd:string" />
<part name="password" type="xsd:string" />
<part name="start_date" type="xsd:string" />
<part name="end_date" type="xsd:string" />
<part name="program_id" type="xsd:int" />
<part name="opt_info" type="xsd:string" />
</message>
- <message name="optionalInfoResponse">
<part name="return" type="xsd:string" />
</message>
the whole WSDL can be found here WSDL service
EDIT:
thanks wrikken, It pushed me in the right direction. I have edited the script a little bit: Now there is an "opt_info" tag. Here I have to put e-mail addresses and a date so that it returns them too. Can anybody help me do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 nusoap 吗? PHP 现在有它自己的 SOAP 处理,这更容易理解(至少对于我作为一个传统的 PHP 程序员来说,我发现 nusoap 有点令人困惑)。如果您刚刚开始学习 SOAP,并且您有一个本地支持它的 PHP 版本,可以使用 --enable libxml(可能需要重新编译以支持 SOAP),那么学习 PHP 的方法可能是个好主意。
下面是一个示例客户端脚本,它发送请求并应该接收响应,它还会打印出“var dump”中的错误:
希望这很有用。顺便说一句:你可以使用 phpinfo(); 检查你的 php 是否有肥皂支持;搜索“soap”,它应该是 --enable-soap
Do you require the use of nusoap? PHP now has it's own SOAP handling which is much easier to understand (At least for me as a traditional PHP programmer, I found nusoap a bit confusing). If you are just starting to learn SOAP and you have a PHP version that supports it natively, with --enable libxml (might need to be recompiled with soap support) it might be a good idea to learn PHP's method.
Here is an example client script that sends a request and should receive a response, it also prints out the errors in a "var dump":
Hope this is useful. BTW: you can check if your php has soap support using phpinfo();, search for "soap" it should read --enable-soap