Professional Documents
Culture Documents
Alliance Conference
March 29, 2011
The Goal
z Open Source
z Free
z Website: soapui.org
Testing a WSDL with soapUI
Click on “Service
Operation
Security”
Service Operation Security
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 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:
PeopleCode to Send the Request
Testing the Request and Response
The SOAP Response
Tim Burns
tim.burns@io-consulting.com
http://training.io-consulting.com
(877) 656-6603
/* **********************************************
"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:*;
/* 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();
/* Send the request and put any reply into the variable &msgResponse */
&msgResponse = %IntBroker.SyncRequest(&msgRequest);
/* 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 */
/********** Sending the XML File to XML Publisher *************/
CommitWork();