Sunday, February 24, 2013

PeopleSoft Pagelet - Consuming a Web Service

I was requested to create some PeopleSoft Portal Pagelets for a demo. I had plan of creating a pagelet that will connect to an external application through integration broker and display resultant data in the pagelet. To achieve this functionality did some search and came across below site that has detail information about creating a web service and pagelet based on integration broker. I was able to successfully create a pagelet by following the instructions.

http://peoplesoft.wikidot.com/consuming-a-web-service

Those who are in PeopleTools greater than 8.50 make sure below highlighted check box "Build Document Messages" is unchecked to build non rowset based messages. For the above pagelet which you are creating this checkbox has to be unchecked.



After creating a pagelet, also planned to create a custom page where user can enter the From Currency and To Currency for conversion.

Below is the page layout I created for this purpose. Below the screenshot I placed the code which I had in field change of the Currency Convertor button.

  
 Below Message is created based on the service operation CONVERSIONRATE that was created based on the steps specified in the above referred site.
 
&msg = CreateMessage(Operation.CONVERSIONRATE);
 
/* Creating the SOAP Request */
&soapReq = CreateSOAPDoc();
&soapReq.AddHeader();
&soapReq.AddEnvelope(%SOAP_Custom);
&EnvNode = &soapReq.EnvelopeNode;
&EnvNode.AddAttribute("xmlns", "http://www.webserviceX.NET/");
&soapReq.AddMethod("ConversionRate", 1);
&soapReq.AddParm("FromCurrency", PORTAL_DR.FROM_CURRENCY);
&soapReq.AddParm("ToCurrency", PORTAL_DR.TO_CURRENCY);
&xmldoc = &soapReq.XmlDoc;
&msg.SetXmlDoc(&soapReq.XmlDoc);
&res = %IntBroker.SyncRequest(&msg);
&Response = &res.GenXMLString();
&myXML = CreateXmlDoc(&Response);
 
/* Extract the Results; */
&myRet = &myXML.GetElementsByTagName("ConversionRateResult");
 
/* Show Result */
MessageBox(0, "", 0, 0, PORTAL_DR.FROM_CURRENCY | " to " | PORTAL_DR.TO_CURRENCY | " = " | &myRet [1].nodevalue);
 

No comments:

Post a Comment