0

I am trying to call a courier api with specified method. I am able to connect with the api using soapclient but getting following error:

Object reference not set to an instance of an object

I am using following code and data

    $proxy = new SoapClient($my_api_url);
    $params = array(
            "UserName" => '****',
            "Password" => '****',
            "OrderNumber" => '41111',
            "ClientName" => 'My Name',
            "ContactNumber1" => '123456789', 
            "EmailAddress" => 'testapi@rohitdhiman.in', 
            "ShippingAddress1" => 'site 15'
            );
    $result = $proxy->BayOneAddOrder($params);
    print_r($result);
Rohit
  • 3
  • 2
  • The *server* had an error, possibly caused by invalid input to it. That is a .NET error message body. Why it didn't properly return a 5xx (barring a more graceful failure), made it be a double-fail on the server's part. Try to generate a valid SOAP message (use a UI for it of course!) to reproduce the issue; if/when you can, *and* it is verified to be a valid SOAP call per the API, send that information to whomever provides the API and tell them to fix it. – user2864740 Sep 22 '15 at 07:15
  • http://stackoverflow.com/questions/8085759/php-soap-net-object-reference-not-set-to-an-instance-of-an-object?rq=1 – user2864740 Sep 22 '15 at 07:19
  • I tried the same request using SOAP UI and it is working fine there – Rohit Sep 22 '15 at 07:20
  • Good start! Then find out what the difference is of the actual SOAP request between the two forms of sending. – user2864740 Sep 22 '15 at 07:21
  • request is same and still not getting response from SOAP client. – Rohit Sep 22 '15 at 10:43
  • Well, *something* must be different. Look at *actual* Over-the-Air SOAP message. – user2864740 Sep 22 '15 at 17:23

1 Answers1

2

If it works using SOAP UI then you can try using a PHP tool like https://providr.io as it will give you the exact PHP request using OOP approach.

If you do not want to use the online tool, then you can generate your own PHP package from your WSDL using PackageGenerator so you'll send request easily still using OOP approach.

Mikaël DELSOL
  • 760
  • 5
  • 15