Run REST Client from Openedge - Forum - OpenEdge Development - Progress Community
 Forum

Run REST Client from Openedge

This question is answered

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!

Verified Answer
  • 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.
  • That's a valid approach, given you are on 10.2B02 or up and on Windows.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

All Replies
  • I found this in 11.3 documentation

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

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

  • 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.

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

    Everything else has to be implemented using Socket calls.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • 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.
  • That's a valid approach, given you are on 10.2B02 or up and on Windows.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • Is there an echo in here?

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • 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.

  • Well, that's a bit silly.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • 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.

  • 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).

  • Hi, please, check this one I have made

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

    or directly on the bitbucket

    bitbucket.org/.../Home