Solved

Error Calling Soap Interface from PHP

Posted on 2013-06-25
5
635 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 75

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 109

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

785 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