Sample XML:
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inf="http://www.ABC.com/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<inf:Method>
<inf:Request>
<Element1>123456</Element1>
<Element2>test2</Element2>
</inf:Request>
</inf:Method/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
PeopleCode using application package:
import PS_PT:Integration:IRequestHandler;
class TEST_IB implements PS_PT:Integration:IRequestHandler
method TEST_IB ();
method OnRequest(&_MSG As Message) Returns Message;
method OnError(&_MSG As Message) Returns string;
end-class;
/* constructor */
method TEST_IB
%Super = create PS_PT:Integration:IRequestHandler();
end-method;
method OnRequest
/+ &_MSG as Message +/
/+ Returns Message +/
/+ Extends/implements PS_PT:Integration:IRequestHandler.OnRequest +/
Local SOAPDoc &SOAPDoc;
Local XmlDoc &lxmlDoc, &responseXMLDoc;
Local XmlNode &EnvNode, &xmln, &Element1, &Element2;
Local Message &lmsgGoRequest, &lmsgGoResponse, &Response;
Local string &string;
Local string &DefNameSpace = "http://www.ABC.com/";
/*Create Soap Document*/
&SOAPDoc = CreateSOAPDoc(); /* required */
&SOAPDoc.AddEnvelope(%SOAP_Schema); /* Pick Scheme from the WSDL*/
/*Add attributes to Schema*/
&EnvNode = &SOAPDoc.EnvelopeNode;
&EnvNode.AddAttribute("xmlns:soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
&EnvNode.AddAttribute("xmlns:inf", "http://www.ABC.com/");
/*Add Soap Header*/
&SOAPDoc.AddHeader();
/*Add Soap Body*/
&SOAPDoc.AddBody(); /* optional */
/*Add first method inf:Method*/
/*1 is for Request, 0 is for Response.*/
&SOAPDoc.AddMethod("inf:Method", 1); /* required */
/*Add Child Nodes*/
&xmln = &SOAPDoc.MethodNode.AddElement("inf:Request");
/*Add Elements - Element1, Element2*/
&Element1= &xmln.AddElement("Element1");
&Element1.NodeValue = "123456"; /*Hardcoded will use setup page to retreive data*/
&Element2= &xmln.AddElement("Element2");
&Element2.NodeValue = "test2"; /*Hardcoded will use setup page to retreive data*/
rem &SOAPDoc.AddMethod("inf:Request", 1); /* required */
rem &SOAPDoc.AddParm("Element1", "123456");
rem &SOAPDoc.AddParm("Element2", "test2");
&lxmlDoc = CreateXmlDoc(&SOAPDoc.GenXmlString());
/* Validate the message */
rem &OK = &SOAPDoc.ValidateSOAPDoc();
/*Create message and Generate XML*/
&lmsgGoRequest = CreateMessage(Operation.TEST_IB);
&lmsgGoRequest.SetXmlDoc(&lxmlDoc);
/* Send the Request */
&Response = %IntBroker.SyncRequest(&lmsgGoRequest);
&responseXMLDoc = &Response.GetXmlDoc();
Return &Response;
end-method;
method OnError
/+ &_MSG as Message +/
/+ Returns String +/
/+ Extends/implements PS_PT:Integration:IRequestHandler.OnError +/
Return &_MSG.IBException.DefaultText;
end-method;