Salesforce

How to consume a SOAP webservice without WSDL using Http Client ?

« Go Back

Information

 
TitleHow to consume a SOAP webservice without WSDL using Http Client ?
URL Namehow-to-consume-soap-webservice-without-wsdl
Article Number000117539
EnvironmentProduct: OpenEdge
Version: 11.7.x, 12.x
OS: All supported platforms
Other: N/A
Question/Problem Description
How to consume a SOAP webservice without WSDL using Http Client ?
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
Http Client (OpenEdge.Net.pl library) can be used to consume a WebService without WSDL. Using this library will allow to submit direct http requests to the web server (based on the URL and get the information from the webservice.  Without the WSDL, it will be responsibility of the developer to know the definition of the SOAP Web Service to consume .

SOAP envelope, SOAP Body and the complete XML request has to be built by the developer and pass it to the Http client. There’s no parsing to validate if the XML is valid and developers would need to know more details on what http headers needs to be included in the http request.

The following ABL procedure shows a sample SOAP request to consume a web service consuming this public WebService : http://www.dneonline.com/calculator.asmx?WSDL

 
USING OpenEdge.Core.*.
USING OpenEdge.Net.HTTP.*.
USING OpenEdge.Net.HTTP.Lib.ClientLibraryBuilder.
USING OpenEdge.Net.URI.

DEFINE VARIABLE oRequest                 AS IHttpRequest                 NO-UNDO.
DEFINE VARIABLE oResponse                AS IHttpResponse                NO-UNDO.
DEFINE VARIABLE oURI                     AS URI                          NO-UNDO.
DEFINE VARIABLE oRequestBody             AS OpenEdge.Core.String         NO-UNDO.
DEFINE VARIABLE hXMLHandle               AS HANDLE                       NO-UNDO.
DEFINE VARIABLE lcXML                    AS LONGCHAR                     NO-UNDO.

//Web Service based on this public WS http://www.dneonline.com/calculator.asmx consuming Add operation 

oRequestBody =  NEW OpenEdge.Core.String('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"><soapenv:Header/><soapenv:Body><tem:Add><tem:intA>1</tem:intA><tem:intB>2</tem:intB></tem:Add></soapenv:Body></soapenv:Envelope>').
oURI = URI:Parse("http://www.dneonline.com/calculator.asmx").
oRequest = RequestBuilder:Post(oUri, oRequestBody)
                         :ContentType('text/xml;charset=UTF-8')
                         :AcceptAll()
                         :AddHeader('SOAPAction', 'http://tempuri.org/Add';)
                         :Request.

oResponse = ClientBuilder:Build()
                         :Client:Execute(oRequest).

IF oResponse:StatusCode <> 200 THEN
   DO:
    MESSAGE "http error: " oResponse:StatusCode VIEW-AS ALERT-BOX. 
    RETURN ERROR "Request Error: " + STRING(oResponse:StatusCode).
   END.
ELSE
  DO:
    hXMLHandle = CAST(oResponse:Entity,WidgetHandle):Value.
    hXMLHandle:SAVE('LONGCHAR',lcXML).
    MESSAGE STRING(lcXML) VIEW-AS ALERT-BOX. 
 END.
    hXMLHandle:SAVE('LONGCHAR',lcXML).
    MESSAGE STRING(lcXML) VIEW-AS ALERT-BOX. 


 
Workaround
Notes
Keyword Phrase
Last Modified Date3/9/2023 6:35 PM

Powered by