Solved

Error Calling Soap Interface from PHP

Posted on 2013-06-25
5
627 Views
Last Modified: 2016-02-10
I have a soap interface (wsdl) that I need to call from a php script.  I have used wsdl2php to build the pcp file describing the classes and methods of the service.  I am getting the posted error when trying to call the service.  Attached, are the file built by WSDL2PHP and the test script to call it.  Also, how should I go about getting the updated header info into the CB_Server class?

When the call to the service is made at line 25:

print $result = $csa_service->GetPayableItemsList($PayableItemList);



Method at line 3598 of CB_Server.php (I get the error even with the code for the return statement removed)

  /**
   *
   *
   * @param GetPayableItemsList $parameters
   * @return GetPayableItemsListResponse
   */
  public function GetPayableItemsList(GetPayableItemsList $parameters) {
    return $this->__soapCall('GetPayableItemsList', array($parameters),       array(
            'uri' => 'https://apps.csa1.com/cmb',
            'soapaction' => ''
           )
      );
  }




I get the following 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\csa_usaEpay\CB_Server.php:3603 Stack trace: #0 C:\xampp\htdocs\csa_usaEpay\CB_Server.php(3603): SoapClient->__soapCall('GetPayableItems...', Array, Array) #1 C:\xampp\htdocs\csa_usaEpay\soapcalltest.php(25): CB_Server->GetPayableItemsList(Object(GetPayableItemsList)) #2 {main} thrown in C:\xampp\htdocs\csa_usaEpay\CB_Server.php on line 3603
soapcalltest.php
CB-Server.php
0
Comment
Question by:sf_gray
  • 3
5 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39276448
Sounds like the server isn't coded properly. Are you sure you've set the values for the data you are sending to appropriate values? Perhaps the developer of the service missed a validation.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39278361
Ask the provider if there is a RESTful interface that you can choose instead.  The world is littered with the rotting carcasses of failed SOAP projects, but I have never seen a REST interface that you could not use immediately with ease.
0
 

Author Comment

by:sf_gray
ID: 39280003
I can call the server from SoapUI tool without issue.  RESTful service is not an option at this time.
0
 

Accepted Solution

by:
sf_gray earned 0 total points
ID: 39280119
Found it!

<?php
            require_once 'CB_Server.php';



            $MultiSpeakMsgHeader = new MultiSpeakMsgHeader('?', 'test', 'test123', '?', '?', '?', 'feet', '?', '?', '?', '?', '?', '?', '?');

            $header = new SoapHeader('http://www.multispeak.org/Version_3.0','MultiSpeakMsgHeader', $MultiSpeakMsgHeader);






            $PayableItemList = new GetPayableItemsList('200001-100001');

            //print $PayableItemList->accountNumber;

            $csa_service = new CB_Server();

            $csa_service->__setSoapHeaders($header);

            print_r($csa_service->__getFunctions());

            //print_r($csa_service->__getTypes());


            //print_r ($result = $csa_service->__SoapCall('GetPayableItemsList',array('GetPayableItemsList'=>(array('accountNumber' => '200001-100001')))));



            print_r ($result = $csa_service->__SoapCall('GetPayableItemsList',array('GetPayableItemsList'=>($PayableItemList))));

                    print "<br />\n Request : ".htmlspecialchars($csa_service->__getLastRequest());

                    print "<br />\n Response: ".htmlspecialchars($csa_service->__getLastResponse());



?>
0
 

Author Closing Comment

by:sf_gray
ID: 39289451
I found a solution to get the results needed.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now