2011-04-28 56 views
0

從PHP文件中,我使用WSDL調用我的函數getCustomerByID(它需要一個整數)並傳入適當的ID。問題在於,即使將ID編碼到函數中,它仍然以NULL的形式傳遞給服務器。SOAP:作爲NULL傳遞的整數

string 'm:Server' (length=8) 
string 'null' (length=4) 
null 
object(stdClass)[83] 
    public 'getCustomerByIdFault1_getCustomerByIdFault' => string 'null' (length=4) 
null 
null 

這裏是WSDL元素:

<?php 
require_once("./include/nusoap/nusoap.php"); 
      $client = new SoapClient('D:\wsdl\CustomerService_CustomerServiceSOAPhttpWithIPAddress.wsdl', array('trace' => 1)); 
      $cId = 100777; 
      echo " CID:".$cId; 
      echo "<br>"; 
      try{ 
       $customerID = $client->getCustomerById(100777); //Error is here. 
       throw new SoapFault('code', 'string', 'actor', 'detail', 'name', 'header'); 
      } 
      catch (Exception $ex) { 
      var_dump($ex->faultcode, $ex->faultstring, $ex->faultactor, $ex->detail, $ex->_name, $ex->headerfault); 
      } 
?> 

這裏是從的try/catch上述吐出

<xsd:element name="getCustomerById"> 
     <xsd:complexType> 
      <xsd:sequence> 
      <xsd:element name="customerId" nillable="true" type="xsd:int"/> 
      </xsd:sequence> 
     </xsd:complexType> 
     </xsd:element> 

任何這裏是什麼是過得去的服務器捕獲,以及服務器的後續回覆:

SENT

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://CustomerServices/customerService"><SOAP-ENV:Body><ns1:getCustomerById/></SOAP-ENV:Body></SOAP-ENV:Envelope> 

您會注意到<ns1:getCustomerById/>不包含任何值。

答覆

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault xmlns:m="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>m:Server</faultcode><detail><service:getCustomerByIdFault1_getCustomerByIdFault xmlns:service="http://CustomerServices/customerService" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"></service:getCustomerByIdFault1_getCustomerByIdFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>

任何想法/建議,非常感謝!

回答

0

你不應該這樣稱呼它:

$client->call('getCustomerById', array('customerId' => 100777))