1 oz C#, 2 oz PHP

Thought I would add some PHP your way. Let’s say we have a C# web service (most are :)) that you want to call from PHP. Now there are ways to handle complex types returned but the easiest way is to return a string. Even then you cannot just assign the result of your C# web service to a string variable in PHP. Here’s how you do it:

#Create a new client variable and point it to your web service WSDL

$client = new SoapClient(“http://www.blahblah.net/StringFunctions.asmx?WSDL”);

#Assign some variables

$username = “Blah”;
$password = “Guess”;

#We pass the parameters in as an array to the method name, note that the array values must match your service input parameters exactly. Note that you append the word Result to your method name (that contains the returning array class

$result = $client->SendBackAStringResult(array(

“my_username” => $username,
“my_password” => $password
));

Leave a Reply

Your email address will not be published. Required fields are marked *