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 OpenEdge.http.net.pl (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".
Info:
OE 11.7.2 64bit
OS Windows 10 Pro.
BTW:
This does not work for me:
IF TYPE-OF(oResponse:Entity, WidgetHandle) then
DO:
DEFINE VARIABLE hXmlDoc AS HANDLE NO-UNDO.
hXmlDoc = cast(oResponse:Entity, WidgetHandle):Value.
hXmlDoc:save('longchar ', SOAPResponseXML).
END.
Why not do it like this? Should be pretty easy to trranslate to OE...
using System.IO;
using System.Net;
String URI = "somesite.com/somepage.html";
WebClient webClient = new WebClient();
Stream stream = webClient.OpenRead(URI);
String request = reader.ReadToEnd();
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 :-)
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 ;-)
Would this code still work if I ported to Linux?
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??
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
OpenEdge.Net.HTTP.Filter.Writer.BodyWriterRegistry:Registry :Put('application/soap+xml':u, get-class(StringBodyWriter))
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?