Wednesday 16 March 2011

Siebel WebService Call - From - PHP

This blog will explain how to call Siebel Web Service from PHP.

This will also shows, how to handle the Siebel complex XML structure in PHP.

Here I am using following WSDL file, I am also giving the Request and Response for the same.

WSDL --> SSO_Service.WSDL (This file is physically located in the PHP code folder)

Note : Please test your Webservice from SOAP Client before you start coding in PHP, so that it will be easy to code.

SOAP Request :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:zeb="http://siebel.com/SOService">
<soapenv:Header/>
<soapenv:Body>
<ns:SSO_spcService_Get_spcUser_spcInfo_Input>
<!--Optional:-->
<ns:User_spcId>SADMIN</ns:User_spcId>
</ns:SSO_spcService_Get_spcUser_spcInfo_Input>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response :


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns:SSO_spcService_Get_spcUser_spcInfo_Output xmlns:ns="http://siebel.com/SSOService">
<ns:NumOutputObjects>1</ns:NumOutputObjects>
<ListOfSsoContact xmlns="http://www.siebel.com/xml/SSOContact">
<Contact>
<EmailAddress>sadmin@company.com</EmailAddress>
<FirstName>Siebel</FirstName>
<LastName>Administrator</LastName>
<LoginName>SADMIN</LoginName>
<Status/>
<Id>0-1</Id>
<ListOfAccount/>
<ListOfResponsibility>
<Responsibility>
<Name>Siebel Administrator</Name>
</Responsibility>
<Responsibility>
<Name>Marketing Analytics Super User</Name>
</Responsibility>
</ListOfResponsibility>
</Contact>
</ListOfSsoContact>
</ns:_spcSSO_spcService_Get_spcUser_spcInfo_Output>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


PHP Code to Handle above SOAP Method :

$soapClient = new SoapClient("SSO_Service.WSDL"); 
$inputParam = array('User_spcId' => 'SADMIN'); 
try  
{   
$info = $soapClient->__call("Get_spcUser_spcInfo", array($inputParam));  
}
catch (SoapFault $fault) { 
echo ' ************ Error ***********' . $fault->faultcode; 
echo ' *************** Error ************' . $fault->faultstring . '
'; 
}

 //NumOutputObjects is Immediate Output 
 echo "
<p> # of Records : " . $info->NumOutputObjects . "</p>";  

$ListOfSsoContact = $info->ListOfSsoContact;
 //Pick the first Contact 
$Contact = $ListOfSsoContact->Contact;
echo '<p> Email Address : ' .$Contact->EmailAddress . ' </p>'; 
echo '<p> First Name : ' .$Contact->FirstName . ' </p>'; 
echo ' <p> Last Name : ' .$Contact->LastName . ' </p>';
?>

Please post your questions if you need more information....