server SOAP+XML response into a Longcha

Posted by CMI on 27-Feb-2018 15:25

Sorry if this question has already been asked but the search function on the community page does not seem to be working correctly.

Using the (httpclient), What is the official way I get the response from the server which returns XML, into a LONCHAR?

The ContentType is "application/soap+xml".


OE 11.7.2 64bit

OS Windows 10 Pro.

All Replies

Posted by CMI on 27-Feb-2018 15:27


This does not work for me:

IF TYPE-OF(oResponse:Entity, WidgetHandle) then

hXmlDoc = cast(oResponse:Entity, WidgetHandle):Value.
hXmlDoc:save('longchar ', SOAPResponseXML).

Posted by goo on 27-Feb-2018 16:02

Why not do it like this? Should be pretty easy to trranslate to OE...

using System.IO;

using System.Net;

String URI = "";

WebClient webClient = new WebClient();

Stream stream = webClient.OpenRead(URI);

String request = reader.ReadToEnd();

Posted by goo on 27-Feb-2018 16:11

def var URI as char no-undo.

def var oWebclient as class System.Net.WebClient no-undo.

def var oStream as class System.IO.Stream no-undo.

def var lc as longchar no-undo.

oWebClient = New System.Net.WebClient().

oStream = New System.IO.Stream().

oStream = oWebClient.OpenRead(URI).



something like this :-)

Posted by bronco on 28-Feb-2018 02:04

Well, not really sure, but I would assume that after:

hXmlDoc = cast(oResponse:Entity, WidgetHandle):Value.

the variable hXmlDoc is already an X-DOCUMENT which contains the entire response from your HTTP call. Works better on Linux as well ;-)

Posted by CMI on 01-Mar-2018 21:39

Would this code still work if I ported to Linux?

Posted by CMI on 01-Mar-2018 21:42

The Problem is the SOAP+XML is some how not being recognised as being ofType 'WidgetHandle'. This may be because the XML does not have a <?xml version="1.0" ?> header. Who knows??

Posted by Peter Judge on 02-Mar-2018 08:00

Somewhere before you call SOAP endpoint, add this line.  This should result in you getting the XML in a LONGCHAR
           :Put('application/soap+xml':u,    get-class(StringEntityWriter))
Note that these are static registries (in the sense that they persist for the lifetime of the session, or until you remove the entry.

Posted by Peter Judge on 02-Mar-2018 08:09

There is also a BodyWriterREgistrty which is used to convert  the 'real' objects into HTTP bodies. If the XML is not real then you may want to add a similar line to handle the input longchar

           :Put('application/soap+xml':u,    get-class(StringBodyWriter))

Posted by CMI on 18-Mar-2018 17:42

Hi, Peter.

So I tried both:

OpenEdge.Net.HTTP.Filter.Writer.EntityWriterRegistry:Registry:Put('application/soap+xml':U,  get-class(StringEntityWriter)).
OpenEdge.Net.HTTP.Filter.Writer.BodyWriterRegistry:Registry:Put('application/soap+xml':u,    get-class(StringBodyWriter)).

and the TYPE-OF(oResponse:Entity, OpenEdge.Core.String) = TRUE but the CAST value of the LONGCHAR has a length of '?'.

Still not sure what is going on here?

Posted by Peter Judge on 19-Mar-2018 10:06

I’m assuming that the request succeeded? With an acceptable status code?
If so, the next step is to check the logs, and then whether anything came back from the server.
Add the below to your code and you should have a fair amount of detail written into the log. You will also have request-raw.txt and response-data-received.txt files in your temp-dir; these are the actual (raw) requests and responses sent to the server.
log-manager:logfile-name = session:temp-dir + 'logging.log'.
log-manager:logging-level = 5.

This thread is closed