Run REST Client from Openedge

Posted by rperuchet@hotmail.com on 28-Jan-2014 03:01

Hi Experts, 

We have done a RESTFUL server in Openedge, it works perfectly. The address where we can get the client is something like this (we use firefox plugin for test it). 

http://10.200.0.220:54985/service/rest/client/client?Id=12345&Emp=11

The problem is when we are trying to make a client access from Openedge. It seems simple, but no documentation found abaut how to do this in Openedge. Any idea?

Thanks!

Posted by Mike Fechner on 28-Jan-2014 03:47

That's a valid approach, given you are on 10.2B02 or up and on Windows.

Posted by rperuchet@hotmail.com on 28-Jan-2014 03:45

I was afraid about this. We have implemented a alternative solution that works in Openedge.

METHOD PUBLIC VOID CallGET(  ):
             
    DEFINE VARIABLE oRequest  AS System.Net.HttpWebRequest  NO-UNDO.
    DEFINE VARIABLE oResponse AS System.Net.HttpWebResponse NO-UNDO.
    
    oRequest = CAST( System.Net.HttpWebRequest:Create( "http://10.0.0.0:54985/service/rest/client/client?Id=12345&Emp=11" ), System.Net.HttpWebRequest ).
    oRequest:Method = "GET".
    oRequest:Credentials = NEW System.Net.NetworkCredential("restmgr", "password").
    
    oResponse = CAST( oRequest:GetResponse(), System.Net.HttpWebResponse ).
    
    txHeaders:Text = 
        oResponse:StatusCode:ToString() + 
        System.Environment:NewLine + 
        oResponse:Headers:ToString().
   
    txResponse:Text = StreamToChar( oResponse:GetResponseStream() ).
    
    CATCH ex AS Progress.Lang.Error :
        MESSAGE "ERROR" ex:GetMessage(1) VIEW-AS ALERT-BOX.
    END CATCH.

END METHOD.

All Replies

Posted by knavneet on 28-Jan-2014 03:09

I found this in 11.3 documentation

documentation.progress.com/.../wwhelp.htm

Posted by knavneet on 28-Jan-2014 03:12

Oh, did you mean calling REST service from OpenEdge? That isn't supported yet...

Posted by Keerthy Yeddula on 28-Jan-2014 03:34

Hi,

Currently there is no support for accessing rest services from OpenEdge. Are you looking for any tool for testing rest services from eclipse?

Thanks,

Keerthy.

Posted by Mike Fechner on 28-Jan-2014 03:37

Simple GET requests can be done from the SAX-READER (XML).

Everything else has to be implemented using Socket calls.

Posted by rperuchet@hotmail.com on 28-Jan-2014 03:45

I was afraid about this. We have implemented a alternative solution that works in Openedge.

METHOD PUBLIC VOID CallGET(  ):
             
    DEFINE VARIABLE oRequest  AS System.Net.HttpWebRequest  NO-UNDO.
    DEFINE VARIABLE oResponse AS System.Net.HttpWebResponse NO-UNDO.
    
    oRequest = CAST( System.Net.HttpWebRequest:Create( "http://10.0.0.0:54985/service/rest/client/client?Id=12345&Emp=11" ), System.Net.HttpWebRequest ).
    oRequest:Method = "GET".
    oRequest:Credentials = NEW System.Net.NetworkCredential("restmgr", "password").
    
    oResponse = CAST( oRequest:GetResponse(), System.Net.HttpWebResponse ).
    
    txHeaders:Text = 
        oResponse:StatusCode:ToString() + 
        System.Environment:NewLine + 
        oResponse:Headers:ToString().
   
    txResponse:Text = StreamToChar( oResponse:GetResponseStream() ).
    
    CATCH ex AS Progress.Lang.Error :
        MESSAGE "ERROR" ex:GetMessage(1) VIEW-AS ALERT-BOX.
    END CATCH.

END METHOD.

Posted by Mike Fechner on 28-Jan-2014 03:47

That's a valid approach, given you are on 10.2B02 or up and on Windows.

Posted by Thomas Mercer-Hursh on 28-Jan-2014 10:15

Is there an echo in here?

Posted by Roberta Miller on 28-Jan-2014 10:22

Yes, there is a little bit of an echo :-). When a post is marked as an "answer", it is copied to the top of the thread so readers don't have to scroll all the way down, but it also stays in it's spot in chronological order. Therefore you will see the "answers" twice in the thread.

Posted by Thomas Mercer-Hursh on 28-Jan-2014 11:25

Well, that's a bit silly.

Posted by Phillip Molly Malone on 30-Jan-2014 20:07

Would have thought the issue with the "echo" is more that the post with the code (even though it is answered by the questioner)(assuming the forum lets it) should be the "answer" not the validation of the code.

JMTC.

PS. Should also mention that REST client would be an enhancement to the product and as such, you may want to add it on the ideas page to start collecting use cases and votes to show PMs how big (or small) and issue it is.

Posted by Phillip Molly Malone on 30-Jan-2014 20:10

This looks great. I have considered if it would be worth building an OpenEdge Class that could do this sort of thing. Perhaps in an Open Source environment so that peeps could add their code/improvements and perhaps their could be a community resolution. Normally I run out of time before I get to trying to nut it out.

(This is my personal idea and has nothing to do with my employer or their feelings on the subject).

Posted by Aleksey on 09-Apr-2014 07:59

Hi, please, check this one I have made

community.progress.com/.../9419.aspx

or directly on the bitbucket

bitbucket.org/.../Home

This thread is closed