2011-03-27 54 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();,搜索「肥皂」它應該閱讀 - 啓用肥皂