2011-08-30 117 views
2

我正在嘗試向我的肥皂webservice發出請求。錯誤的請求生成肥皂客戶端php

class DateTime2 extends DateTime { 
     function __toString() { 
      return $this->format("d/m/Y H:i"); 
     } 
    } 
    $date = new DateTime2(); 

    $client = new SoapClient("http://www.myos.it/sp/smartphonelayer.asmx?wsdl",array("trace" => 1)); 
    $result = $client->SetReservation("Mario Rossi",2,"",$date.""); 
    echo "REQUEST:".$client->__getLastRequest()."<br>"; 
    print_r($result); 

輸出我得到的是:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"> 
    <SOAP-ENV:Body> 
     <ns1:SetReservation/> 
     <param1>2</param1> 
     <param2>3286026817</param2> 
     <param3>2011-08-30T07:10:32</param3> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 
<br>stdClass Object 
(
    [SetReservationResult] => stdClass Object 
    (
     [Success] => SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. 
      [DeskCode] => 
      [Message] => 
     ) 

) 

正如你可以看到我只得到3通過創建SoapClient的請求參數時,我給它4個parameteres。

+0

你能後的WSDL? –

回答

2

發送你需要使用數組()

而且對日期時間參數,需要XML格式如下

class DateTime2 extends DateTime { 
    function __toString() { 
     return $this->format("Y-m-d\TH:i:s.000\Z"); 
    } 
} 
$date = new DateTime2(); 
$client = new SoapClient("http://www.myos.it/sp/smartphonelayer.asmx?wsdl",array("trace" => 1)); 

$result = $client->SetReservation(array("RDescription"=>"Giuseppe Silvestri", 
             "RNumber"=>2, 
             "RPhoneNumber"=>"3286026817", 
             "RDate"=>$date."")); 
echo "REQUEST:".$client->__getLastRequest()."<br>"; 
print_r($result); 
+0

它工作!謝啦!你能解釋我爲什麼需要使用數組作爲參數嗎? – radon90