Help in converting Code in PHP for Web Service Security

sandipwaghole's picture
Hello we are executing an application for web service security where we have a code in C# and using WSF/PHP we are trying to make it in PHP.   We are using the methods defined in wsdl.   We were able to execute few lines from C#. Kindly help us to execute further lines.   We have the C# Code as   using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;   using xyz.serverABC; using Microsoft.Web.Services3; using Microsoft.Web.Services3.Security; using Microsoft.Web.Services3.Security.Tokens;   public partial class _Default : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         //Added Web Reference to         //http://xyz.serverABC/PeopleSoftService/AI_WSL_ORD_KI.1.wsdl           // Create license order Service proxy with WSE security         AI_WSL_ORD_KIWse OrdWS = new AI_WSL_ORD_KIWse();           // Set authentification token (User, Password)         UsernameToken UserToken = new UsernameToken("APP_USER", "XXXX", PasswordOption.SendPlainText);         OrdWS.RequestSoapContext.Security.Tokens.Add(UserToken);         OrdWS.RequestSoapContext.Security.Timestamp.TtlInSeconds = 60;           // Create inputs for order creation         Create__Intfc__WSL_ORD_KITypeShape OrdWSInputs = new Create__Intfc__WSL_ORD_KITypeShape();           WSL_ORDCUSTTypeShape Customer = new WSL_ORDCUSTTypeShape();         WSL_ORDMAILTOTypeShape MailTo = new WSL_ORDMAILTOTypeShape();           Customer.Value = "33331";         MailTo.Value = "xxx@abc.com";           OrdWSInputs.WSL_ORDCUST = Customer;         OrdWSInputs.WSL_ORDMAILTO = MailTo;           // Call create method with input parameters         Create__Intfc__WSL_ORD_KIResponseType OrdWSResponse = OrdWS.CI_METHOD(OrdWSInputs);           // Retrieve ID for order created         string OrderID = OrdWSResponse.detail.WSL_ORD_KI.WSL_ORDID.Value;     } } WSDL Contents are as follows     <wsp:UsagePolicy wsdl:Required="true" /> - <plnk:partnerLinkType name="CI_CRM_PartnerLinkType"> - <plnk:role name="CI_CRM_Provider">   <plnk:portType name="tns:CI_CRM_PortType" />   </plnk:role>   </plnk:partnerLinkType> - <wsdl:types> - <xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">   <xsd:import namespace="http://xmlns.oracle.com/Enterprise/Tools/schemas/M386446.V1" schemaLocation="M386446.V1.xsd" />   <xsd:import namespace="http://xmlns.oracle.com/Enterprise/Tools/schemas/M774702.V1" schemaLocation="M774702.V1.xsd" />   </xsd:schema>   </wsdl:types> - <wsdl:message name="M386446.V1">   <wsdl:documentation>M386446</wsdl:documentation>   <wsdl:part element="M386446.V1:Create__CompIntfc__CRML_ORD_CI" name="parameter" />   </wsdl:message> - <wsdl:message name="M774702.V1">   <wsdl:documentation>M774702</wsdl:documentation>   <wsdl:part element="M774702.V1:Create__CompIntfc__CRML_ORD_CIResponse" name="parameter" />   </wsdl:message> - <wsdl:portType name="CI_CRM_PortType"> - <wsdl:operation name="CI_METHOD">   <wsdl:documentation>CI_METHOD</wsdl:documentation>   <wsdl:input message="tns:M386446.V1" name="M386446.V1" />   <wsdl:output message="tns:M774702.V1" name="M774702.V1" />   </wsdl:operation>   </wsdl:portType> - <wsdl:binding name="CI_CRM_Binding" type="tns:CI_CRM_PortType">   <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> - <wsdl:operation name="CI_METHOD">   <soap:operation soapAction="CI_METHOD.V3" style="document" /> - <wsp:Policy wsu:Id="UsernameTokenSecurityPolicyPasswordRequired" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> - <wsp:ExactlyOne> - <wsp:All> - <wsse:SecurityToken wsp:Usage="wsp:Required" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">   <wsse:TokenType>wsse:UserNameToken</wsse:TokenType> - <Claims>   <SubjectName MatchType="wsse:Exact" />   <UsePassword wsp:Usage="wsp:Required" />   </Claims>   </wsse:SecurityToken>   </wsp:All>   </wsp:ExactlyOne>   </wsp:Policy> - <wsdl:input name="M386446.V1">   <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal" />   </wsdl:input> - <wsdl:output name="M774702.V1">   <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal" />   </wsdl:output>   </wsdl:operation>   </wsdl:binding> - <wsdl:service name="CI_CRM">   <wsdl:documentation>CI_CRM</wsdl:documentation> - <wsdl:port binding="tns:CI_CRM_Binding" name="CI_CRM_Port">   <soap:address location="http://xyzserver/PSIGW/SoftServiceListeningConnector" />   </wsdl:port>   </wsdl:service>   </wsdl:definitions>     We were able to execute it like   $wsdl_link="xyz.wsdl";   $user_name="USER_NAME";   $user_pass="Password";   $pass_type="Plain";   $method_name=”CI_METHOD";   $sec_array = array("useUsernameToken" => TRUE);   $policy = new WSPolicy(array("security"=>$sec_array));   // Create user Token Object   $user_token = new WSSecurityToken(array("user" => $user_name,                                               "password" => $user_pass,                                            "passwordType" =>$pass_type));       // We have another reference Setting Time Stamp we need it along with using username & Password     $client = new WSClient(array("wsdl"=>$wsdl_link));     $parameters = array('WSL_ORDCUST'=> 'Test Webservice',                            'WSL_ORDMAILTO' => 'asgh@ashjsd.com',                                             'CRML_ORDID' => 'test');    // Acces to WSDL  # Method 1  $client = new WSClient(array("wsdl"=>$wsdl_link));  $proxy = $client->getProxy();    echo "Before Invoking method in WSDL<br>";    // Call a method in WSDL  $res =  $proxy-> CI_METHOD($parameters);   echo "After Invoking method in WSDL<br>"; print_r($res);     // # Method 2 /* $operations = array("CI_METHOD ");   $svr = new WSService(array("wsdl"=>$wsdl_link, "operations" => " CI_METHOD",$parameters));   $svr->reply();  */       We got the following error after execution :-   Method 1 Output Before Invoking method in WSDL After Invoking method in WSDL   Method 2 Output SOAP-ENV:ServerBad Request. Can't find HTTP_RAW_POST_DATA     Please help us to write PHP Code.   Regards, Sandip Waghole  
buddhika's picture

Re:Help in converting Code in PHP for Web Service Security

Hi Sandip,     WSDL mode support for security is under developing and it is not working with WSF/PHP 1.0.0 or 1.1.0 release.If you could send us the WSDL file we can try your scenario and let us know. Then you may be able to try it from our nightly builds. Please note that in current developing implementation of WSDL mode does not work with import schema.So please make sure to send us the WSDL with inline schema.   Thanks Buddhika
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)