2011-03-27 57 views
2

我遇到了下面的脚本有问题。它只是不想回复任何回应。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 service

编辑:

感谢wrikken,它把我推在正确的方向。我已经编辑了一小段脚本:现在有一个“opt_info”标签。在这里,我必须把电子邮件地址和日期,以便它也返回。有人能帮我做这个吗?

+0

最有可能的逻辑/数据错误(例如,一个无效的program_id,所以数据缺少),因为代码似乎没有问题。您是否尝试过正常的内置肥皂客户端? – Wrikken 2011-03-28 20:27:07

+0

@wrikken我编辑了这篇文章。它的确行得通,只是它不能检索任何东西,因为我没有发送任何东西,你能帮助我吗? – damage000 2011-03-29 21:05:45

回答

0

你需要使用nusoap吗? PHP现在拥有自己的SOAP处理,这更容易理解(至少对于我来说,作为传统的PHP程序员,我发现nusoap有点混乱)。如果你刚刚开始学习SOAP,并且你有一个本地支持它的PHP版本,使用--enable libxml(可能需要用soap支持重新编译),那么学习PHP的方法可能是一个好主意。

下面是一个例子客户端脚本发送请求和应该收到响应,它也打印出错误的“VAR转储”:

 <?php 
     try { 
      $sClient = new SoapClient("http://URL-TO-WSDL"); 
      $response = $sClient->doFunctionName($REQUEST); 
//doFunctionName should represent the name of the "message" element 
//and $REQUEST is what you are sending to the server for that same message element 
      print_r($response); 
     } catch(SoapFault $error) { 
      var_dump($error); 
     } ?> 

希望这是非常有用的。顺便说一句:你可以检查你的php是否有肥皂支持使用phpinfo();,搜索“肥皂”它应该阅读 - 启用肥皂