WordPress: Call ASMX web service from PHP?
How about a scenario, where you have a brand new virgin machine, and you have been asked a question on how, a php code would call an asmx from a WordPress website?
So, you have literally nothing: No visual studio, no TextPad, no Notepad++, no IIS installed anywhere over the network, no php editor, no server to deploy php code -- Do you think you can answer the question? No?
Think again!
1. Access to internet -- is enough! http://writecodeonline.com/
2. Now, how to test calling an ASP.NET web service? Google... for free online ASP.NET web services, you'd find lots. Following simple services helped us with the testing:
- http://ws.cdyne.com/NotifyWS/
phonenotify.asmx?op= NotifyPhoneBasic - http://www.webservicex.net/
stockquote.asmx?op=GetQuote
Following code goes into the php script file:
echo "Script Start\n\n";
try
{
//1. create object
$client = new SoapClient("http://www.
//2. fill params
$object = new stdClass();
$object->symbol = "MSFT";
//3. Call web method
print_r($client->GetQuote($
}
catch (SoapFault $exception) { echo $exception; }
echo "Script complete\n\n";
Worked fairly well.
Enjoy!