Help setting up a Rest service.

Posted by Paul Radbone on 24-Apr-2014 07:01

Hi,

I have managed to set up a OE rest project.  I've configured the appserver/web server and a simple method in a class is deployed.

When I try and access the below url, I am prompted for a username/password.  Where is the username/password set or what is the default?  I can't test my service and I'm really stuck at this point!

http://localhost:8980/oerm/applications/testRestService

Thanks,

Paul.

All Replies

Posted by Sanjeva Manchala on 24-Apr-2014 07:10

Hi Paul,
 
You can provide username/password as restmgr/password.
 
Regards,
Sanjeev.
 
[collapse]
From: paul.radbone@wins.co.uk [mailto:bounce-paulradbonewinscouk@community.progress.com]
Sent: 24 April 2014 PM 05:33
To: TU.OE.Development@community.progress.com
Subject: Help setting up a Rest service.
 
Thread created by paul.radbone@wins.co.uk

Hi,

I have managed to set up a OE rest project.  I've configured the appserver/web server and a simple method in a class is deployed.

When I try and access the below url, I am prompted for a username/password.  Where is the username/password set or what is the default?  I can't test my service and I'm really stuck at this point!

http://localhost:8980/oerm/applications/testRestService

Thanks,

Paul.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Paul Radbone on 24-Apr-2014 07:23

Thanks.  I can see the users setup in the tomcat-users file...

this is working now, but when I make a request to the URL that i have set up, I get the following:

405 Method Not Allowed

the method is GET, which is what I have exposed and set up in the defined services?

Cheers,

Paul.

Posted by Irfan on 24-Apr-2014 07:24

HI Paul,
 
If you would like to access the OpenEdge REST Manager then you might need to access the URL http://localhost:8980/oerm. The purpose of OE REST Manager is to deploy,enable,disable, undeploy and maintain the properties and statistics of the REST Applications.
 
To access your REST Application, then your URL would be http://localhost:8980/<REST-Application>/rest    where <REST-Application> is your deployed REST Application name.
 
I believe your REST Application’s name is testRESTService, hence to access the WADL of your REST Service you need to access http://localhost:8980/testRESTService/rest. By looking at the WADL you should be able to identify the Path’s to access your resources.
 
Regards,
Irfan
 
[collapse]
From: paul.radbone@wins.co.uk [mailto:bounce-paulradbonewinscouk@community.progress.com]
Sent: Thursday, April 24, 2014 5:33 PM
To: TU.OE.Development@community.progress.com
Subject: Help setting up a Rest service.
 
Thread created by paul.radbone@wins.co.uk

Hi,

I have managed to set up a OE rest project.  I've configured the appserver/web server and a simple method in a class is deployed.

When I try and access the below url, I am prompted for a username/password.  Where is the username/password set or what is the default?  I can't test my service and I'm really stuck at this point!

http://localhost:8980/oerm/applications/testRestService

Thanks,

Paul.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Paul Radbone on 24-Apr-2014 09:18

Hi,

none of the url's you suggested worked.  if I look in the Server monitor (as screen shot) it says the url is http://localhost:8980/oerm/applications/testRestService/

I'm totally lost here...

Paul.

Posted by Anil Kumar on 24-Apr-2014 10:53

Hi Paul,

If the application/service is deployed properly to OE Webserver (Tomcat) then invoking http://localhost:8980/testRestService/rest should result in list of all available RESTful services (in this case http://localhost:8980/testRestService/rest/testRestService?_wadl) and from this section you can access the actual WADL file which will show complete information of the service (like URL, resources).

For more information on the REST URI construction please refer 'Understanding REST Web application URI construction' section in this link

The URL shown in the Server monitor view in PDS OE was pointing to wrong URL in 11.3 version and was addressed in 11.3.1 release.

Thanks and Regards,

Anil Kumar.

Posted by Michael Jacobs on 24-Apr-2014 10:56

Paul,

You are being mislead by the information contained in the server monitor's 'REST service URL'.   It confused me also.  The URL field's value will not physically exist in the web server ( at least not in any of my REST projects )

Like Irfan said, the 'oerm' web application is a remote management agent (displayed as 'restmgr1') and does not contain any of the REST services you create in your project.   When you create a REST service in your project and the development studio publishes your service (using 'restmg1') it does so by creating a new web application and deploying it to the web server using the REST service interface's name.

From the screen shot I see the name of your REST service interface is 'testRestService', which will produce and deploy a web application named 'testRestServcie'.   The URL to access your new REST service web application would be:

    http://localhost:8980/testRestService

I generally do an initial manual test to see if the web application ended up where I would expect it and will it start and run:

a) do a GET on 'http://localhost:8980/testRestService and see if it will return anything

b) do a GET on ''http://localhost:8980/testRestService/rest/'  and see if anything is returned

You want to get a 200 response from b) before proceeding further.   Do note that b) can return success, but does not mean that your REST web application is actually able to connect to the AppServer.   For AppServer connection testing you have to access one of your web application's resources that is mapped to a class/procedure in the AppServer.

Try that and see if you get further.

Posted by Paul Radbone on 24-Apr-2014 11:15

Hi Success!!

I had 2 issues.  one was that I needed to edit the web.xml file to specify which security method to use.  Now this is working, if I hit the url:

http://localhost:8980/testRestService/rest/testRestService?_wadl

I get the following output:

<application xmlns="wadl.dev.java.net/.../02" xmlns:xs="www.w3.org/.../XMLSchema">

<grammars/>

<resources base="http://localhost:8980/testRestService/rest/testRestService">

<resource path="/randomNumber">

<method name="GET">

<response status="204"/>

</method>

</resource>

<resource path="/randomNumber2">

<method name="GET">

<response status="204"/>

</method>

</resource>

</resources>

</application>

So my next question is how do I hit the randomNumber resource and get a response?

Thanks for the help.

Paul.

Posted by Paul Radbone on 24-Apr-2014 11:40

OK, I'm getting somewhere.....

http://localhost:8980/testRestService/rest/testRestService/randomNumber

this produces an error:

{"_errors":[{"_errorMsg":"ERROR condition: randomNumber Singleton object instantiation ended with an ERROR condition. (16819) (7211)","_errorNum":16819}]}

this is from the Rest service log:

2014-04-24 17:36:29.153 [INFO][REST] An HTTP Request received in Enabled State. Sending Request to the Adapter Servlet.

2014-04-24 17:36:29.155 [INFO][REST] OpenEdge Procedure name: randomNumber

2014-04-24 17:36:29.156 [INFO][REST] OpenEdge Internal Procedure name: myRandomNumber

2014-04-24 17:36:29.156 [INFO][REST] Executing a SingleRun class

2014-04-24 17:36:29.156 [INFO][REST] Internal procedure name is myRandomNumber

2014-04-24 17:36:29.156 [INFO][REST] Running an internal procedure: randomNumber->myRandomNumber

2014-04-24 17:36:29.163 [ERROR][REST] ABL Runtime error

2014-04-24 17:36:29.163 [ERROR][REST] Exception in AppServerProducer :: ABL Runtime error

2014-04-24 17:36:29,163 1652785 [http-bio-8980-exec-295] ERROR org.apache.camel.processor.DefaultErrorHandler error  - Failed delivery for (MessageId: ID-cb-wks-prad-w7-50245-1398355683027-0-13 on ExchangeId: ID-cb-wks-prad-w7-50245-1398355683027-0-14). Exhausted after delivery attempt: 1 caught: com.progress.open4gl.Open4GLException: ABL Runtime error

com.progress.open4gl.Open4GLException: ABL Runtime error

at com.progress.caf.camel.component.oe.AppServerCamelEndpoint.runClassMethod(AppServerCamelEndpoint.java:569)

at com.progress.caf.camel.component.oe.AppServerProducer.process(AppServerProducer.java:108)

at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

Posted by Paul Radbone on 24-Apr-2014 11:59

more info.  I looked in the appserver log and found this:

[14/04/24@17:50:56.514+0100] P-010144 T-010100 2 AS AS Application Server Startup. (5473)

[14/04/24@17:56:05.518+0100] P-009224 T-008388 1 AS -- ** "randomNumber" was not found. (293)

[14/04/24@17:56:05.518+0100] P-009224 T-008388 1 AS -- Cannot load class 'randomNumber' (16815)

[14/04/24@17:56:05.518+0100] P-009224 T-008388 1 AS -- randomNumber Singleton object instantiation ended with an ERROR condition. (16819)

Does this mean that it didnt deploy succesfully?  I'm not sure what to do next..

Posted by Michael Jacobs on 24-Apr-2014 12:23

Paul,

You are doing much better.

Just a guess, but I would say there was a deployment problem.   Check the AppServer configuration's PROPATH and verify that the class file(s) are able to be found.

Posted by Paul Radbone on 25-Apr-2014 02:31

Thanks for the help everyone.  It's working for me now.  I had missed out adding the project directory to the appserver properties/modules, so the code wasn't being deployed!

Does anyone know how the licensing works for this kind of product in a production environment?  is it on a per server basis?

Thanks,

Paul.

This thread is closed