6

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?

Kenster
  • 23,465
  • 21
  • 80
  • 106
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139

2 Answers2

10

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

Anthony
  • 2,014
  • 2
  • 19
  • 29
d-_-b
  • 6,555
  • 5
  • 40
  • 58
  • Thanks for the reply sims! When I call $funcs = $soapclient->__getFunctions(); print_r($funcs); I get the same error? SOAP_Fault Object ( [error_message_prefix] => [mode] => 1 [level] => 1024 [code] => soap:Client [message] => Server did not recognize the value of HTTP Header SOAPAction: . [userinfo] => – jerrygarciuh Oct 20 '10 at 15:14
  • OK, well, then the problem runs deeper and is more likely a config problem... A search turned up somethings about XML name spaces:http://bluebones.net/2003/07/server-did-not-recognize-http-header-soapaction/ – d-_-b Oct 21 '10 at 02:35
  • BTW, are you using a WSDL file/URL? – d-_-b Oct 21 '10 at 02:39
  • Hi Sims. Thank you again for your help with this. Definitely learned new things. Turned out they had issues in their WSDL file and once those were corrected my calls worked. Much obliged! – jerrygarciuh Oct 21 '10 at 13:49
  • Yeah, sometimes it's "the other guys" fault - esp when they are stuck in one technology. Good luck! – d-_-b Oct 22 '10 at 04:36
  • Note for anyone using __getLastRequest(), be sure to turn on "trace" when you create the SoapClient object. See http://php.net/manual/en/soapclient.getlastresponse.php#60365 – rlorenzo Dec 19 '13 at 00:54
0

for debug purpose you can use Fiddler web debuger. I found it quite useful. In these days I'm working on a project based on .net web services, and I have to consume them via PHP. This is a working (and very simple) piece of code. Hope this can help you. The purpose of this piece of code is to check a status on a specific record.

This is the wsdl

POST /b1synccontext.asmx HTTP/1.1
Host: 00.00.00.0
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/QueueEntryGetStatus"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <QueueEntryGetStatus xmlns="http://tempuri.org/">
      <BuffID>int</BuffID>
    </QueueEntryGetStatus>
  </soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <QueueEntryGetStatusResponse xmlns="http://tempuri.org/">
      <QueueEntryGetStatusResult>int</QueueEntryGetStatusResult>
    </QueueEntryGetStatusResponse>
  </soap:Body>
</soap:Envelope>

This is the php code

$client = new SoapClient("http://YOURIP/yourservice.asmx?wsdl",array(
                        'exceptions'=>true,
                        'cache_wsdl'=>WSDL_CACHE_NONE,
                        'encoding'=>'utf-8'));
$params = array(
    'BuffID' => 134
    );

try 
    {
        $result = $client->QueueEntryGetStatus($params);
        $status = $result->QueueEntryGetStatusResult;
        /*do something*/ 
    } 
    catch (Exception $e) 
    {
        $e -> getMessage();
        /*do something*/
    }
Luca
  • 108
  • 1
  • 11