Thursday, August 1, 2013

Building SOAP Message for 3rd Party Integration

If you need to integrate with a third party system using SOAP in PeopleSoft, you can save some time by utilizing HTML objects to store your SOAP Envelope in PeopleSoft.  For instance, BrassRing's Dispatch service has a web service flavor that uses the following SOAP Message.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Dispatch xmlns="http://trm.brassring.com/HRIS">
      <HRXML/>
    </Dispatch>
  </soap:Body>
</soap:Envelope>


You could use the the xmldoc class to create this exact schema and then send it in your message to BrassRing, or you can do something like this.

 &DispatchWebService = CreateXmlDoc(GetHTMLText(HTML.ZZ_DISPATCH_SOAP));
  
  &node = &DispatchWebService.DocumentElement.FindNode("/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='Dispatch']/*[local-name()='HRXML']");
   

Rem add message detail to hrxml node for brassring to process;
&nodeValue = &node.AddText(&Message.GenXmlString());


Where HTML.ZZ_DISPATCH_SOAP is equal to the SOAP schema above.  The only issue with this method is that it will not work in an Application Engine, as you cannot use the GetHTMLText function in AE.  So you can simply write your own Function to pull the SOAP Envelope out, that way you can keep your code agnostic and only have one version of it running in AE and online.


Function get_html_text(&html As string) Returns string
   rem change this to record object;
   SQLExec("Select Contdata From  Pscontent Where Conttype = 4 And Contname = :1", &html, &blob);   
   Return &blob; 
  
End-Function;


Now you change your CreateXMLDoc Call to this:


 &DispatchWebService = CreateXmlDoc(Get_HTML_Text("ZZ_DISPATCH_SOAP"));

 Now you are ready to send this message in SOAP. 







  

No comments:

Post a Comment