Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call asp.net web service from PHP with multiple parameters

I'm using a method using SoapClient class in a php page to call a web service in an asp.net site.

Here is the php code.

$client = new SoapClient("http://testurl/Test.asmx?WSDL");

$params = array( 'Param1'  => 'Hello', 
                'Param2' => 'World!');

$result = $client->TestMethod($params)->TestMethodResult;

echo $result;

The problem is, I'm only getting the first parameter (Param1) "Hello" back and seems like there is an issue with Param2. Here is the asp.net method.

[WebMethod]
public string TestMethod(string Param1, string Param2) 
{
    return Param1 + " " +  Param2; 
}

What am I missing to get Hello World! in the response?

like image 715
Felasfaw Avatar asked Mar 14 '12 22:03

Felasfaw


1 Answers

Try like this:

$client = new SoapClient("http://testurl/Test.asmx?WSDL");
$params->Param1 = 'Hello';
$params->Param2 = 'World!';    
$result = $client->TestMethod($params)->TestMethodResult;
like image 164
Darin Dimitrov Avatar answered Sep 18 '22 12:09

Darin Dimitrov