PHP SOAP pass form array to WSDL on remote server

Posted on 2007-03-20
Last Modified: 2013-11-18
Dear Experts.

I am stuck on a small problem with PHP5 Soap / WSDL.

I need to pass the contents of a form to fill a WSDL on another server. This needs to be sent as an array.

The array is sent as a $param and I have attemted to do it like this:

$weborder = array('OrderID'=>$OrderID,'UserName'=>$UserName,'Password'=>$Password,'CusID'=>$DealerID,'SiteID'=>$DealSiteID,'Title'=>$title,'CusFname'=>$fname,'CusLName'=>$lname, 'BillAddr1'=>$addr1,  'BillAddr2'=>$addr2, 'BillAddr3'=>$addr3, 'BillAddr4'=>$addr4, 'BillPCode'=>$postc, 'BillPhone'=>$phone, 'BillMobile'=>$mobile,  'BillEmail'=>$email);

$param["WebsiteOrder"] = $Weborder;

$client = new SoapClient("");
$RIOresult = $client -> ReadInOrder($param);

And my hope was that it would populate this WSDL correctly

 <ReadInOrder xmlns="">


But the best I can get is this error

Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\Inetpub\wwwroot........etc

Can anyone help me decifer the problem and set me on the path to enlightenment!

many thanx

Question by:imagicstudios
1 Comment

Accepted Solution

cubical10 earned 500 total points
ID: 18775110
Build a test file to display how php is parsing the wsdl.
Instantiate the SoapClient with the option array('trace' => 1), this will enable some debug options.
$server = 'http://someserver/path/to/wsdl.wsdl';
$client = new SoapClient($server, array('trace' => 1));

echo '<h4>Available Methods</h4>';

$methods = $client->__getFunctions();
echo "<ol>\n";
foreach ($methods as $k => $method) {
            echo "<li>$method</li>";
echo "</ol>\n";

echo "<h4>Supported Types</h4>";
$types = $client->__getTypes();
echo "<ol style=\"white-space: pre;\">\n";
foreach ($types as $k => $type) {
            echo "<li>$type</li>";
echo "</ol>\n";

This file will now list all of the available methods and list the types needed to use those methods.
The methods will be listed as ReturnStuct methodName(RequestStruct $requestVariable).

You will have to connect the dots so to speak.  As usually the RequestStruct is made up of other structs.  If you share the output of the file above, i can help you some more.

You can add the following code to above file to view the generated soap request envelope and response.

$parameters = //array or object or string or whatever...
      try {
            $data = $client->methodName($parameters);
      } catch (SoapFault $soapFault) {
            echo $soapFault;
      $request = $client->__getLastRequest();
      $request = str_replace('><',">\n<",$request);
      echo "<hr><textarea rows='20' cols='250' style='background-color: #dddddd; color: blue;'>$request</textarea>";
      $response = $client->__getLastResponse();
      $response = str_replace('><',">\n<",$response);
      echo "<hr><textarea rows='20' cols='250' style='background-color: #eeeeee; color: purple;'>$response</textarea>";

As a final note, if the RequestStruct is of an Abstract type, then you are going to need to build your request parameter with SOAPVar:

Hope this helps...


Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses how to create an extensible mechanism for linked drop downs.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

770 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