peoplesoft web service to xml publisher report
DESCRIPTION
Consume an external, non-PeopleSoft web service. Present the data that comes back from the web service in an XML Publisher report that pops up in a separate browser window. Do all of this from the click of a pushbutton on a PeopleSoft page.TRANSCRIPT
![Page 1: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/1.jpg)
Alliance ConferenceMarch 29, 2011
Web Services and XML Publisher:A Step-by-Step Guide to Using
Them Together
![Page 2: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/2.jpg)
The GoalThe Goal
Consume an external, non-PeopleSoft web service
Present the data that comes back from the web service in an XML Publisher report that pops up in a separate browser window
Do all of this from the click of a pushbutton on a PeopleSoft page
![Page 3: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/3.jpg)
Test an external web service
Create a PeopleSoft page to “consume” the web service (send the request and capture the response)
Design an XML Publisher report to display the data that is received from the web service
Put PeopleCode behind a pushbutton to request data from the web service and display the data immediately via XML Publisher
AgendaAgenda
![Page 4: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/4.jpg)
The web service steps demonstrated here require that you have Integration Broker setup and working:
SetupSetup
Gateway
IntegrationGateway.properties file
Service Configuration page
![Page 5: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/5.jpg)
Steps to Consume a Web ServiceSteps to Consume a Web Service
1. Test the WSDL with soapUI
2. Paste a valid WSDL URL into the PeopleSoft "Consume Web Service" Wizard, and step through the wizard
3. Examine the Service Definition and Service Operations that are generated
4. Apply Appropriate Service Operation Security to the Service Operation(s)
5. Create a page, component, and content reference, and write appropriate PeopleCode to initiate the request and consume the response from the outside service
![Page 6: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/6.jpg)
Web Services Description LanguageWeb Services Description LanguageWSDLWSDL
A WSDL is an XML document that provides information about what the service does, the methods that are available, their parameters, and parameter types. It describes how to communicate with the service in order to generate a request to, or decipher a response from, the service.
![Page 7: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/7.jpg)
soapUIsoapUI
Open Source
Free
Website: soapui.org
![Page 8: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/8.jpg)
Testing a WSDL withTesting a WSDL with soapUIsoapUI
Create a new project in soapUI
Paste in your WSDL
Use the automatically-generated request to enter parameters and test the request and verify the response
![Page 9: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/9.jpg)
Testing a WSDL withTesting a WSDL with soapUIsoapUI
Example WSDL URL:
http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl
![Page 10: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/10.jpg)
Consuming a Web ServiceConsuming a Web Service
PeopleSoft provides a wizard to Consume a Web Service
PeopleTools > Integration Broker > Web Services > Consume a Web Service
![Page 11: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/11.jpg)
Consume Web Service WizardConsume Web Service Wizard
Example WSDL URL:
http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl
![Page 12: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/12.jpg)
The View WSDL hyperlink allows you to view the WSDL in a browser window:
Consume Web Service WizardConsume Web Service Wizard
![Page 13: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/13.jpg)
Examining a WSDLExamining a WSDL
Example WSDL URL:
http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl
Here is the WSDL displayed in a browser:
![Page 14: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/14.jpg)
If your selected service has more than one port, you select one here:
Consume Web Service WizardConsume Web Service Wizard
![Page 15: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/15.jpg)
Select one or more service operations here:
Consume Web Service WizardConsume Web Service Wizard
![Page 16: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/16.jpg)
Request and response messages are created. The internal names of these messages can be changed to more meaningful names.
Consume Web Service WizardConsume Web Service Wizard
![Page 17: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/17.jpg)
The internal service name and default node name are automatically inserted here.
Consume Web Service WizardConsume Web Service Wizard
![Page 18: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/18.jpg)
Consume Web Service WizardConsume Web Service WizardConfirm ResultsConfirm Results
Click “View Consumed Service” to view all the created definitions.
![Page 19: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/19.jpg)
The Service DefinitionThe Service Definition
A link to the service operation appears at the bottom:
![Page 20: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/20.jpg)
The Service OperationThe Service Operation
Click on “Service Operation Security”
![Page 21: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/21.jpg)
Service Operation SecurityService Operation Security
A Service Operation must be tied to at least one permission list:
![Page 22: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/22.jpg)
The RoutingThe Routing
Looking at the generated routing for the service operation:
![Page 23: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/23.jpg)
A Page for Testing the Web ServiceA Page for Testing the Web Service
In this example, all of the fields on the page are derived/work fields. PeopleCode is placed in the FieldChange event of the pushbutton:
![Page 24: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/24.jpg)
In this example, all of the fields on the page are derived/work fields. PeopleCode is placed in the FieldChange event of the pushbutton:
A Page for Testing the Web ServiceA Page for Testing the Web Service
![Page 25: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/25.jpg)
PeopleCode to Send the RequestPeopleCode to Send the Request
![Page 26: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/26.jpg)
Testing the Request and Response Testing the Request and Response
![Page 27: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/27.jpg)
The SOAP ResponseThe SOAP Response
The data that comes back from the web service includes a SOAP envelope
Extract just the XML data from the response, without the SOAP envelope and header information
Save that basic XML as a file (with the .xml extension) to use as a sample XML file to design your report template for XML Publisher
![Page 28: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/28.jpg)
Extracting the Relevant XMLExtracting the Relevant XML
![Page 29: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/29.jpg)
The PeopleCodeThe PeopleCode
• All of the PeopleCode discussed and demonstrated here appears at the end of this presentation.
• This pushbutton code invokes the web service, parses the response and writes it to an XML file, and sends that file to XML Publisher. The XMLP report appears in a separate browser window.
![Page 30: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/30.jpg)
Steps to Create an XMLP Report based Steps to Create an XMLP Report based on an XML File (rather than a Query)on an XML File (rather than a Query)
1. Generate the XML sample data file (in this scenario it is extracted from the SOAP response received from the web service)
2. Define the Data Source
3. Create the Template (.rtf file)
4. Create the Report Definition
5. Run and test the XMLP Report
![Page 31: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/31.jpg)
Define the Data SourceDefine the Data Source
Reporting Tools > XML Publisher > Data Source
On the “Data Source” search page, select Add a New Value:
![Page 32: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/32.jpg)
Define the Data SourceDefine the Data Source
When the Data Source page displays, upload the xml file extracted from the web service response. Save the Data Source definition.
![Page 33: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/33.jpg)
Create the XMLP TemplateCreate the XMLP Template
• Open up Microsoft Word. The Template Builder (aka “Design Helper”) facilitates the layout of the report.
• If you are using Word 2007, click on the “Add-Ins”tab to see the menu items for the Template Builder:
• On the Template Builder menu, click on the Data menu bar, and select “Load XML Data…”
• Load the XML file that you extracted from the SOAP response.
![Page 34: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/34.jpg)
Create the XMLP TemplateCreate the XMLP Template
Save the template document as an RTF file
Add a title to the template
Use the Design Helper Table Wizard to insert one or more tables, groups, etc.
Where there is hierarchical data, tables can be nested
![Page 35: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/35.jpg)
Create the XMLP TemplateCreate the XMLP Template
This template has nested tables:
![Page 36: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/36.jpg)
Create the XMLP TemplateCreate the XMLP Template
Use the preview menu to look at the output in PDF format
![Page 37: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/37.jpg)
Create the Report DefinitionCreate the Report Definition
Reporting Tools > XML Publisher > Report Definition
Add a new report definition:
![Page 38: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/38.jpg)
Create the Report DefinitionCreate the Report Definition
![Page 39: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/39.jpg)
Create the Report DefinitionCreate the Report Definition
Upload the RTF template:
![Page 40: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/40.jpg)
Create the Report DefinitionCreate the Report Definition
Output Tab – Format Options
![Page 41: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/41.jpg)
Pushbutton PeopleCodePushbutton PeopleCode
Add more FieldChange PeopleCode to your existing pushbutton.
This code will associate the XML file (response) with your report definition and launch the report.
The ViewOutput method is used if you want the report to appear right away in a separate browser window.
![Page 42: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/42.jpg)
Pushbutton PeopleCodePushbutton PeopleCode
![Page 43: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/43.jpg)
Test the Finished ApplicationTest the Finished Application
On the custom web page, the user enters the parameters and clicks the pushbutton. The external web service is invoked and the data in the response is written to an XML file which is passed to XML Publisher, and the resulting report pops up in a separate browser window.
![Page 44: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/44.jpg)
The Report OutputThe Report Output
![Page 45: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/45.jpg)
Contact InformationContact Information
io Consulting - Booth 321
Tim Burns
http://training.io-consulting.com
(877) 656-6603
![Page 46: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/46.jpg)
/* ********************************************** "Web Services and XML Publisher - A Step-by-Step Guide to Using Them Together" This code goes with the corresponding presentation slides. Alliance Conference - 2011 - Denver, CO. -- Session Number:29274, March 29, 2011 Tim Burns, io Consulting http://training.io-consulting.com/training-technical.php ********************************************** */ /* The following code was placed in the FieldChange event of a pushbutton. In addition to the pushbutton, the page has 3 other derived/work fields: ZIP, TRN_DISTANCE_XX, and RAWXML1. */ import PSXP_RPTDEFNMANAGER:*; /********** Beginning of Adapted Code ***********************/ /********** Adapted from Larry Roux's code -- Begin -- ********** "Integrating with External Systems using Web Services" Alliance Session 27112, March 2, 2010 Larry Roux, Syracuse University */ Local SOAPDoc &soapReq; Local XmlNode &nodeEnv, &node_Wanted; Local XmlDoc &xmldocRequest, &xmldocResponse, &xmldocNew; Local Message &msgRequest, &msgResponse; Local string &strXMLrqst, &strResponse, &strNodeWanted, &strGetTheatersNode, &strReadLine, &strOutDestFormat; Local File &fileResponse, &fileIn, &fileOut; Local PSXP_RPTDEFNMANAGER:ReportDefn &oReportDefn; /******************* Request ***************************/ /* instantiate the SoapDoc object */ &soapReq = CreateSOAPDoc(); /* manually add SOAP XML envelope, header, body, method and parameters */ &soapReq.AddEnvelope(%SOAP_Custom); &nodeEnv = &soapReq.EnvelopeNode; &nodeEnv.AddAttribute("xmlns:SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"); &nodeEnv.AddAttribute("xmlns:what", "http://www.ignyte.com/whatsshowing"); &soapReq.AddMethod("what:GetTheatersAndMovies", 1); &soapReq.AddParm("what:zipCode", TRN_DERIVED_XX.ZIP); &soapReq.AddParm("what:radius", String(TRN_DERIVED_XX.TRN_DISTANCE_XX)); &strXMLrqst = &soapReq.GenXmlString(); /* This instantiates the XML object */ &xmldocRequest = CreateXmlDoc(&strXMLrqst); /* This creates the message based on the IB Service Operation */ &msgRequest = CreateMessage(Operation.GETTHEATERSANDMOVIES, %IntBroker_Request); &msgRequest.SetXmlDoc(&xmldocRequest); /* Send the request and put any reply into the variable &msgResponse */ &msgResponse = %IntBroker.SyncRequest(&msgRequest); /********** Adapted from Larry Roux's code -- End -- **********/ /********** End of Adapted Code ***************************/
![Page 47: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/47.jpg)
/* Optional: For testing/debugging, display the outbound request in a derived/work field on a page in the same component */ REM &RequestStr = &msgRequest.GenXMLString(); REM TRN_DERIVED_XX.RAWXML2 = &RequestStr; /* Optional: Display the result that came back (the unformatted SOAP response), using a derived/work field */ &strResponse = &msgResponse.GenXMLString(); TRN_DERIVED_XX.RAWXML1 = &strResponse; &xmldocResponse = &msgResponse.GetXmlDoc(); /* Opening a text file to which I will write the node that I want (and it's child nodes) */ &fileResponse = GetFile("c:\temp\fileResponse.txt", "W", %FilePath_Absolute); /* Identifying the node that I want from the SOAP response, so that I can use the FindNode method and eliminate the SOAP envelope. I adapted the following statement from a posting by David Sexton on the IT Toolbox website: http://it.toolbox.com/blogs/extending-apps/findnode-in-peoplecode-34321 */ &strNodeWanted = "soap:Body//*[local-name()=" | """" | "GetTheatersAndMoviesResult" | """" | "]"; &node_Wanted = &xmldocResponse.DocumentElement.FindNode(&strNodeWanted); /* I am creating a new XmlDoc and copying the desired node from the SOAP response to this new XmlDoc object. I then write this out to a text file */ &xmldocNew = CreateXmlDoc("<?xml version='1.0'?><root/>"); &xmldocNew.DocumentElement.CopyNode(&node_Wanted); &strGetTheatersNode = &xmldocNew.GenFormattedXmlString(); &fileResponse.WriteString(&strGetTheatersNode); &fileResponse.Close(); /* At this point, the resulting text file (&fileResponse) still contains text that I do not want. I want to clean up the XML file a little more before I send it to XML Publisher. */ /* Read/Write from one flat file to another, eliminating unwanted elements and attributes */ &fileIn = GetFile("c:\temp\fileResponse.txt", "R", %FilePath_Absolute); &fileOut = GetFile("c:\temp\out.xml", "W", %FilePath_Absolute); While &fileIn.ReadLine(&strReadLine) If &strReadLine <> "<root>" And /* Removing this element from the final XML file */ &strReadLine <> "</root>" Then If Find("xmlns", &strReadLine, 29) > 0 Then /* Removing the "xmlns" attribute from the final XML file */ &fileOut.WriteLine("<GetTheatersAndMoviesResult>"); Else &fileOut.WriteLine(&strReadLine); End-If; End-If; End-While; &fileIn.Close(); &fileOut.Close(); /* Now I have a simple and clean XML file that I can easily use with my XML Publisher template */
![Page 48: PeopleSoft Web Service to XML Publisher Report](https://reader033.vdocuments.site/reader033/viewer/2022051210/5513ee064a7959c4028b4df4/html5/thumbnails/48.jpg)
/********** Sending the XML File to XML Publisher *************/ /* Specify the Report Definition */ &oReportDefn = create PSXP_RPTDEFNMANAGER:ReportDefn("MOVIES"); &oReportDefn.Get(); /* Establish the Data Source (XML File) for the Report */ &oReportDefn.SetRuntimeDataXMLFile("c:\temp\out.xml"); /* Generate the Report */ &strOutDestFormat = &oReportDefn.GetDefaultOutputFormat(); /* The first parameter of the ProcessReport method specifies the template ID (from the report definition) */ &oReportDefn.ProcessReport("MOVIES_1", "", %Date, &strOutDestFormat); CommitWork(); /* Display the Report in a separate browser window */ &oReportDefn.DisplayOutput();