Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging PHP SOAP call

Tags:

php

soap

I am new to SOAP and dealing with a web service where it would seem no one has interfaced using PHP previously. They have no example code excepting C# but I do have that. eServices.asmx provides WSDL if that is the correct way to say that.

The error that I am getting is "Server did not recognize the value of HTTP Header SOAPAction:" with that training colon suggesting no value is passed, maybe.

My code looks like this:

$URL = "http://nolaflash.example.com/xxxWS/eServices.asmx";

$namespace="http://www.example.com/webservices/";

include("SOAP/Client.php");

$soapclient = new SOAP_Client($URL);

$xml_data = // valid XML is here;

$res = $soapclient->UpdateData('usrname','pass',$xml_data);

but I have also tried:

$param = array('usrname','pass',$xml_data);
$res = $soapclient->call('UpdateData',$param, $namespace);

Googling suggests that this error is a namespace issue. The C# code I have has only one namespace reference:

[System.Web.Services.WebServiceBindingAttribute(Name="eServicesSoap", Namespace="http://www.example.com/webservices/")]

If I dump $soapclient to the screen prior to the function call I see that it has received data from eServices.asmx.

I am unsure how to go about debugging this and the staffers at the service are unfamiliar with interacting with the service outside their .NET IDE.

Any thoughts? Advice?

like image 499
jerrygarciuh Avatar asked Oct 20 '10 00:10

jerrygarciuh


People also ask

How do you debug a SOAP request?

The easiest and best* way to debug a SOAP request is indeed to create a SOAP extension that logs the raw SOAP request and the raw SOAP response from the Web service or Web service client using the following functions of the SoapClient class: SoapClient::__getLastRequestHeaders. SoapClient::__getLastRequest.

How can make SOAP call in PHP?

To make SOAP requests to the SOAP API endpoint, use the "Content-Type: application/soap+xml" request header, which tells the server that the request body contains a SOAP envelope. The server informs the client that it has returned a SOAP envelope with a "Content-Type: application/soap+xml" response header.


1 Answers

I usually use the methods getFunctions and getLastRequest to help me sort things out. First I look at the function list and WSDL. Sometimes the WSDL and/or server is not setup/configured/coded properly. So this function list may be useless. The WSDL file should be definitive, but alas, lame coders, etc...

So sometimes I have to take a stab in the dark, look at the error, and then look at the last request. With this you can see the actual XML that was produced. Compare that to some working XML examples.

This has proven most helpful when dealing with coders who don't want to write docs. By the way, they should give XML examples - not show how to generate XML using language XYZ. There may be more useful infos in the PHP/Soap documentation

HTH

like image 165
d-_-b Avatar answered Sep 23 '22 07:09

d-_-b