Thursday, August 13, 2009

Invoking webservice using php

Yah, I just finished primary work for an online application. Basically I just learned how to use SOAP to access a webservice using php.
PHP 5 has introduced SoapClient class to do such things. Following is the code that I used :

$wsdl_url = "http://urltowebservice.wsdl";
$client = new SoapClient($wsdl_url);
$params = array('pasrm1'=>7, 'param2'=>'EN');
try {
$objectResult = $client->SomeMethod($params);
echo $objectResult->ResponseResult;
} catch (SoapFault $exception) {
echo $exception;

Reference :
If you are interested about working with simpler SOAPS without using a wsdl file you can check the following: