Hi,
I am trying to use OpenEdge.Net.pl. The propath is C:/JCA/OpenEdge.Net.pl and I have include the libray, compiler is giving below error messages:
Impossibile trovare la classe o interfaccia OpenEdge.Net.HTTP.RequestBuilder. (12886)
** Impossibile interpretare linea 1. (196)
Impossibile trovare la classe o interfaccia OpenEdge.Net.HTTP.IHttpRequest. (12886)
** Impossibile interpretare linea 2. (196)
Tipo di dati specificato non valido: IHttpRequest. Specificare un tipo di dati come 'character' o il nome di una classe. (5638)
** Impossibile interpretare linea 5. (196)
OpenEdge V. 11.7 and OS - Windows.
Thanks in advance,
G.
|
is a simple code from Progress documentation. I copy openedge.net.pl from C:\JCA\OpenEdge\gui\netlib
USING OpenEdge.Net.HTTP.RequestBuilder.
USING OpenEdge.Net.HTTP.IHttpRequest.
DEFINE VARIABLE httpUrl AS CHARACTER NO-UNDO.
DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.
httpUrl = "http://www.progress.com".
oRequest = RequestBuilder:Get(httpUrl)
:Request.
And for some confirmation that it really does work see: abldojo.services.progress.com:443/
I found the problem. It's not enough to save library on propath folder, but insert it in the propath string (PROPATH=c:\jca,c:\jca\xml,c:\jca\OpenEdge.Net.p)
Many thanks.
Hi,
I run this program:
USING Progress.Json.ObjectModel.JsonObject.
USING Progress.Json.ObjectModel.ObjectModelParser.
USING Progress.Lang.Object.
USING OpenEdge.Core.WidgetHandle.
USING OpenEdge.Core.String.
USING OpenEdge.Net.HTTP.IHttpRequest.
USING OpenEdge.Net.HTTP.IHttpResponse.
USING OpenEdge.Net.HTTP.ClientBuilder.
USING OpenEdge.Net.HTTP.RequestBuilder.
DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.
DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO.
DEFINE VARIABLE oEntity AS Object NO-UNDO.
DEFINE VARIABLE lcHTML AS LONGCHAR NO-UNDO.
DEFINE VARIABLE hXmlDoc AS HANDLE NO-UNDO.
oRequest = RequestBuilder:Get('obsv:5493/.../Clients')
:Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).
oEntity = oResponse:Entity.
MESSAGE
oResponse:StatusCode SKIP
oResponse:StatusReason SKIP
VIEW-AS ALERT-BOX.
IF TYPE-OF(oEntity, JsonObject) THEN
CAST(oEntity, JsonObject):WriteFile('temp/entity.json', true).
ELSE
IF TYPE-OF(oEntity, WidgetHandle) THEN
DO:
hXmlDoc = CAST(oEntity, WidgetHandle):Value.
hXmlDoc:save('file', 'temp/entity.xml').
END.
ELSE
DO:
IF TYPE-OF(oEntity, String) THEN
lcHTML = CAST(oEntity, String):Value.
ELSE
lcHTML = oEntity:ToString().
/* Change extension per the Response's ContentType */
CASE oResponse:ContentType:
WHEN 'application/json' THEN
COPY-LOB lcHTML TO FILE 'temp/entity.json'.
WHEN 'text/html' THEN
COPY-LOB lcHTML TO FILE 'temp/entity.html'.
OTHERWISE
COPY-LOB lcHTML TO FILE 'temp/entity.txt'.
END CASE.
This string return a correct XML but OE cannot save as 'temp/entity.xml" but a simple txt file that contain "OpenEdge.Core.ByteBucket_7196".
May can help me?
You will want to replace
IF TYPE-OF(oEntity, String) THEN lcHTML = CAST(oEntity, String):Value. ELSE lcHTML = oEntity:ToString().
With something like
case true: when type-of(oEntity, String) then lcHTML = cast(oEntity, String):Value. when type-of(oEntity, Memptr) then lcHTML = cast(oEntity, Memptr):GetString(1). when type-of(oEntity, ByteBucket) then lcHTML = cast(oEntity, ByteBucket):GetString(). otherwise lcHTML = oEntity:ToString(). end case.
That should get you want you're after/
Thanks Peter. I replaced but I found error for Memprt:
Impossibile trovare la classe o interfaccia Memptr. (12886)
TYPE-OF 'Memptr' non consentito. TYPE-OF di destinazione deve essere di tipo definito dall'utente. (14447)
** Impossibile interpretare linea 47. (196)
Thanks a lot.
|
USING OpenEdge.Core.* .
now work fine. Create entity.txt that contains XML structure data.
Why do not create direcly entity.xml?
Thx.
Because of this CASE statement
/* Change extension per the Response's ContentType */ CASE oResponse:ContentType: WHEN 'application/json' THEN COPY-LOB lcHTML TO FILE 'temp/entity.json'. WHEN 'text/html' THEN COPY-LOB lcHTML TO FILE 'temp/entity.html'. OTHERWISE COPY-LOB lcHTML TO FILE 'temp/entity.txt'. END CASE.
There's no check for XML. Add a WHEN with the appropriate XML and you should be good.
I found WHEN 'application/atom+xml' THEN
COPY-LOB lcHTML TO FILE 'temp/entity.xml'.
many thanks.
Thanks Peter work fine.
I add in the code:
oCredentials = new Credentials('application', 'amministratore', 'Its@55!').
oRequest = RequestBuilder:Get('obsv:5493/.../Clients')
:AcceptJson()
:UsingBasicAuthentication(oCredentials)
:Request.
But OE do not create an XML file but entity.txt with contains different data format as application/octet-stream.
I have to pass only user and password.
Thx.
Hi Peter,
resolved with these lines:
// Create credentials
oCredentials = new Credentials('some-domain', 'amministratore', '123456').
oRequest = RequestBuilder:Get('obsv:5493/.../ClientDocuments')
// Add credentials to the request
:UsingBasicAuthentication(oCredentials)
:Request.
This work fine. Now I have to PUT data into. DO you have some suggestion to give me?
Thx.
Thanks. Sorry another question: and for POST?
Inviato dal mio dispositivo Huawei
Update from Progress Community
Peter Judge Put is very similar.RequestBuilder:Put(<uri>, <message-body>):Request.The <message-body> will depends on what you’re sending. You can send a variety of data (JSON, XML, binary, etc).You can see all the options at documentation.progress.com/.../OpenEdge.Net.HTTP.RequestBuilder.htmlYou received this notification because you subscribed to the forum. To unsubscribe from only this thread, go here.
Flag this post as spam/abuse.
|
The previuos example is wrong. I need to send XML. maybe there is an example.
Thx
Hi Peter,
I tried a lot of solutions without success. My problem is to define object for XML data file. An help is appreciate. Thx a lot in advance.
xmlfile = "c:/jca/temp/entity.xml".
hXmlRequestData:LOAD("LONGCHAR", xmlfile, FALSE).
httpUrl = "obsv:5493/.../Clients".
oXmlRequestData = NEW WidgetHandle(hXmlRequestData).
oRequest = RequestBuilder:POST(httpUrl, oXMLRequestData):ContentType("application/xml")
:AcceptXml()
:Request.
DEFINE VARIABLE hXmlRequestData AS HANDLE NO-UNDO.
DEFINE VARIABLE oXmlRequestData AS WidgetHandle NO-UNDO.
You need to create the X-DOC handle first.
DEF VAR hXmlRequestData AS HANDLE.
CREATE X-DOCUMENT hXmlRequestData.
hXmlRequestData:LOAD(...)
Alternatively you can just try
DEF VAR lxXml AS LONGCHAR.
COPY-LOB FILE "c:/jca/temp/entity.xml" to lcXml.
oRequest = RequestBuilder:POST(httpUrl, NEW OpenEdge.Core.String(lcXml))
:AcceptJson() /* we want to get JSON back */
:Request.
|
|
|
|
|
|
|
|
|
This is a connection error, although that looks like an odd port for a web server you should still try to connect to the same URL (http://obsv:5493) in a web browser on the same machine where you try to connect from the Progress session. If it fails in the browser too then check the name resolution (DNS), doing a ping to 'obsv' does it at least translate the host name to an IP address (ping packages might not go through though). If the host name is resolved to an IP address then there might be other network related issues that makes the host unreachable, like being in a different network and no bridge set-up or simply a firewall on the server or somewhere in between (a router maybe). If the host name is not resolved to an IP address then you need to get the DNS setup fixed or obtain the server IP address and use that instead of the host name.