简体   繁体   中英

Consume ASP.NET WebService In php and return soap error

i am trying to calling .net webservice in php below is my code.

<?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' => '01237 376347',
                                '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);

    ?>

i have got this error Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\\xampp\\htdocs\\test2.php:33 Stack trace: #0 C:\\xampp\\htdocs\\test2.php(33): SoapClient->__soapCall('UpdateInstructi...', Array) #1 {main} thrown in C:\\xampp\\htdocs\\test2.php on line 33

You probably need to send something like:

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

Where Instruction is the name of the object that you are passing.

It looks like a NullReferenceException was thrown on the server side. So, it's a matter of the parameters to whatever function is occurring on the server side generating that error.

Regardless of why, per best practices, this is an error in the .NET service. The NullReferenceException should really be replaced with something more specific.

Can you get in touch with whomever wrote the service to get more information to troubleshoot? It's quite possible that you have a parameter misnamed in your $params array, but you're probably going to need some help from the service writer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM