2011-05-18 37 views
1

我想調用.net webservice在php 下面是我的代碼。消費ASP.NET WebService在PHP和返回SOAP錯誤

<?php 
    $client = new SoapClient("http://test.etech.net/PanelIntegration/PanelIntegration.asmx?wsdl"); 

     <?php 
     $sh_param = array( 
          'Username' => 'IntegratorLPI', 
          'Password' => 'password531'); 
       $headers = new SoapHeader('http://wms.etech.net/', 'UserCredentials', $sh_param); 
       $client->__setSoapHeaders($headers); 



       $params = array('CustomerName' => 'Mr Smith','ContactMobileNo' => '', 
           'AddressLine1' => '33 Amblecote Road', 
           'AddressTown' => 'Cambridgeshire', 
           'AddressPostCode' => 'NW23 6TR', 
           'VendorAddressLine1' => '80 Norton Road', 
           'VendorAddressTown' => 'Hickley ', 
           'VendorAddressCounty' => 'Cambridgeshire', 
           'VendorAddressPostCode' => 'NW23 2AQ', 
           'RegionalOfficeID' => '3', 
           'ExternalNotes' => 'Case Accepted', 
           'UPRN' => '', 
           'InstructionTypeID' => '2', 
           'PropertyTypeID' => '11', 
           'PropertyTenure' => '2', 
           'SurveyorID' => '23', 
           'RRN' => '0240-9002-0391-3520-0020', 
           'NewInstruction'=> 'true', 
           'StatusID' => '1' 
           ); 
       $result = $client->__soapCall("UpdateInstruction", $params); 

       print_r( $result); 

    ?> 

我有這個錯誤 致命錯誤:未捕獲的SOAPFault例外:肥皂:服務器]服務器無法處理請求。 --->對象引用未設置爲對象的實例。在C:\ xampp \ htdocs \ test2.php中:33堆棧跟蹤:#0 C:\ xampp \ htdocs \ test2.php(33):SoapClient - > __ soapCall('UpdateInstructi ...',Array)#1 {main }在第33行拋出C:\ xampp \ htdocs \ test2.php

回答

0

看起來在服務器端拋出了NullReferenceException。所以,這是服務器端產生該錯誤的任何函數的參數問題。

不管爲什麼,根據最佳實踐,這是.NET服務中的錯誤。 NullReferenceException應該真的被更具體的東西取代。

您可以聯繫誰寫的服務獲取更多的信息排除故障?很有可能您的$params陣列中有一個參數名稱錯誤,但您可能需要服務編寫人員提供一些幫助。

+0

安德魯感謝您的回覆,但這個網絡服務工作正常,當我用.net調用相同的參數。任何其他方式來調用這個服務在PHP中。謝謝 – 2011-05-19 03:27:04

1

你可能需要發送類似:

$result = $client->__soapCall("UpdateInstruction", array('Instruction' => $params); 

其中instruction是要傳遞的對象的名稱。