SOAP Client Question

I’m having a problem which I don’t understand. I’m trying to implement a SOAP call to an external entity for a client and I’m running into an issue…

I’m making the soap client call pretty much the standard way (at least from any permutation I can find…)


        $client = new SoapClient('http://store.example.com/dirName/WebService.asmx?WSDL');
        $response = $client->__soapCall('MethodName', array("Attribute1" => "value1", "Attribute2" => "value2"));

But when I execute it, I get the following error…

[h=2]System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Exception: Attribute1 and Attribute2 are required
at dbReg.DataWebService.MethodName(String Attribute1, String Attribute2)
--- End of inner exception stack trace ---[/h]

here is the appropriate section of the wsdl


[[B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]s:element name[/COLOR][COLOR=#0000ff]="MethodName[/COLOR][COLOR=#0000ff]">[/COLOR] [URL="http://www.sitepoint.com/forums/"][B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B]](http://www.sitepoint.com/forums/) [COLOR=#0000ff]<[/COLOR][COLOR=#990000]s:complexType[/COLOR][COLOR=#0000ff]>[/COLOR]
[[B][FONT=Courier New][COLOR=#ff0000]-[/COLOR][/FONT][/B]](http://www.sitepoint.com/forums/) [COLOR=#0000ff]<[/COLOR][COLOR=#990000]s:sequence[/COLOR][COLOR=#0000ff]>[/COLOR]
[B][FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT][/B] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]s:element[/COLOR] [COLOR=#990000]minOccurs[/COLOR][COLOR=#0000ff]="[/COLOR][B]0[/B][COLOR=#0000ff]"[/COLOR][COLOR=#990000] maxOccurs[/COLOR][COLOR=#0000ff]="[/COLOR][B]1[/B][COLOR=#0000ff]"[/COLOR][COLOR=#990000] name[/COLOR][COLOR=#0000ff]="[/COLOR][B]Attribute1[/B][COLOR=#0000ff]"[/COLOR][COLOR=#990000] type[/COLOR][COLOR=#0000ff]="[/COLOR][B]s:string[/B][COLOR=#0000ff]" />[/COLOR] 

[B][FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT][/B] [COLOR=#0000ff]<[/COLOR][COLOR=#990000]s:element[/COLOR] [COLOR=#990000]minOccurs[/COLOR][COLOR=#0000ff]="[/COLOR][B]0[/B][COLOR=#0000ff]"[/COLOR][COLOR=#990000] maxOccurs[/COLOR][COLOR=#0000ff]="[/COLOR][B]1[/B][COLOR=#0000ff]"[/COLOR][COLOR=#990000] name[/COLOR][COLOR=#0000ff]="Attribute2[/COLOR][COLOR=#0000ff]"[/COLOR][COLOR=#990000] type[/COLOR][COLOR=#0000ff]="[/COLOR][B]s:string[/B][COLOR=#0000ff]" />[/COLOR] 

[B][FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT][/B] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]s:sequence[/COLOR][COLOR=#0000ff]>[/COLOR]


[B][FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT][/B] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]s:complexType[/COLOR][COLOR=#0000ff]>[/COLOR]


[B][FONT=Courier New][COLOR=#ff0000] [/COLOR][/FONT][/B] [COLOR=#0000ff]</[/COLOR][COLOR=#990000]s:element[/COLOR][COLOR=#0000ff]>
[/COLOR]

I’ve also tried using $client->__call(‘MethodName’, array(“Attribute1” => “value1”, “Attribute2” => “value2”)); and $client->MethodName(array(“Attribute1” => “value1”, “Attribute2” => “value2”)); (which basically generates the __soapCall call systematically) and get the same results.

This is the first time I’ve done SOAP via php (I’ve done it with .net, java and classic asp), but I’m not sure what I’m missing. What should be my first steps in debugging this?

Try this:
$response = $client->MethodName(array(“Attribute1” => “value1”, “Attribute2” => “value2”));

I did not see that you have already tried that.

In this case try to wrap your arguments in another array(), like this:

$response = $client->__soapCall(‘MethodName’, array(array(“Attribute1” => “value1”, “Attribute2” => “value2”) ));

It may work, I’m not sure, but I think I’ve had a similar problem and it worked for me

Grrr…I know I tried this (both with and without the array), and it didn’t work before, but now it does… sigh. Thanks for the heads up.