Sample PeopleCode to Invoke Webservices from Command Push Button

You can invoke webservice from a button fieldchange event also .

using &Request = CreateMessage(Operation.serviceoperation_name, %IntBroker_Request);

Example:-
&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", "USD");
&soapReq.AddParm("ToCurrency", "CAD");
&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, "USD to CAD = " | &myRet [1].nodevalue);

--------------------------------------------------------------------------------------------------
/* all are not required ,take the values from wsdl") */
&EnvNode.AddAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
&EnvNode.AddAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
&EnvNode.AddAttribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope");
&EnvNode.AddAttribute("xmlns", "http://www.xignite.com/services");

No comments:

Post a Comment

PeopleCode to retrieve Google map between two addresses

  PeopleCode Example: /* Define constants for the API request */ Local string &origin = "123 Main St, Anytown, USA";   /* ...