Software Defined Networking
1830241 Members
1630 Online
109999 Solutions
New Discussion

Re: REST API's display in RSdoc of Controller

 
SatishK
Frequent Advisor

REST API's display in RSdoc of Controller

Hi All,

 

I have created internal application with REST API's and i'm able to upload and deploy successfully ,but i'm not able to see the REST API's created  in RSdoc of controller.

 

I'm accessing RSdoc is  using  this link https://172.20.58.132:8443/api. Please help me in resolving this issue.

 

Thanks in advance.

 

 

11 REPLIES 11
Chethan_R
Occasional Advisor

Re: REST API's display in RSdoc of Controller

 

 

Hi All,

 

 

    I'm also facing the same problem and in my case application is getting deployed , But i'm not able see my application name in RSdoc page accessed using https://x.x.x.x:8443/api/ which inturn resulting in non exposure of REST API's. I have  attached a screen shot where my app name is not getting listed as shown.

 

   I'm using a HP Proliant G7 server with 60 days trial version of controller. 60 days had been finished and so i'm doubting regarding the controller i have installed.

 

So please help me in resolving this.

 

Thanks in advance.

 

 

 

 

 

piricchio72
Valued Contributor

Re: REST API's display in RSdoc of Controller

Hello,

 

Few questions:

 

1) is the application listed as ACTIVE from the controller GUI?

2) Did you restart the controller after deploying the app?

3) did you reload RsDoc page after deploying the application?

4) Did you try to authenticate in RsDoc before trying to access the application?

5) Can you eventually provide the application for further tests?

 

Regards,

 

Antonio

ADN Team

Chethan_R
Occasional Advisor

Re: REST API's display in RSdoc of Controller

Hi,

 

Thanks for ur reply. As you asked, The controller is  showing  active in GUI and performed all the next three steps but still i'm not able to see REST API's created. As the application is in development phase, I have just implemented REST API's with fake implementations. I have followed every step of controller programming guide in creation of REST API's . Even I'm not able  to access REST API's using   Curl commands. So please help me resolving this issue.

 

Thanks in advance.

 

piricchio72
Valued Contributor

Re: REST API's display in RSdoc of Controller

Hello,

 

following the Programming Guide 2.4 (page 83):

 

The tool offered by the HP VAN SDN Controller SDK that generates the RSdoc takes the

Javadoc to generate the REST API documentation. Therefore, it is mandatory to write Javadoc for

the REST APIs (In general, production code classes should be properly documented). If a REST API

method does not contain Javadoc, the entire REST API will not be included in the RSdoc.

 

Did you write the javadoc?

 

Regards,

 

Antonio

SDN CoE

 

Chethan_R
Occasional Advisor

Re: REST API's display in RSdoc of Controller

 

HI,

 

Thanks for your reply. Actually i'm not able to access the REST API's created even using CURL commands.

 

My application is deployed successfully and even showing active state .

 

The CURL command  used to access my REST is shown below and i'm getting this error response when below cmnd is executed and my REST API's path is "routers" as shown in command .

 

So why i'm not able to access my REST API's even using CURL commands. Please  help me in resolving.

 

Thankyou.

 

 

CMD=($ curl -sk -H "X-Auth-Token:31f90410e68347a4810ad80f295f7aae" _https://x.x.x.x:8443/sdn/v1.0/routers)


Response=(<html><head><title>Apache Tomcat/7.0.35 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,
sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-
serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;
color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:
black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}
A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - Not Found</h1><HR
size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Not Found</u></p><p><b>description</b> <u>The requested resource is not available.
</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.35</h3></body></html>)

piricchio72
Valued Contributor

Re: REST API's display in RSdoc of Controller

Hello,

 

Concerning the Curl command you provided:

 

CMD=($ curl -sk -H "X-Auth-Token:31f90410e68347a4810ad80f295f7aae" _https://x.x.x.x:8443/sdn/v1.0/routers)

 

Is the "_" in front of the https://x.x.x.x:8443/sdn/v1.0/routers an typo?

 

Why are you using V1.0?

 

Regards,

 

Antoino

SDN CoE

 

Chethan_R
Occasional Advisor

Re: REST API's display in RSdoc of Controller

Hi SDN CoE,

 

Thanks for the Swift reply,

 

Yes its a typo mistake, there is no "_" before http.

The below curl command is working fine, 

curl -sk -H "X-Auth-Token:9a3939a6949a45efaeb6b6860292886f" https://172.20.58.132:8443/sdn/v2.0/systems

 

but same is not working with routers, (my rest API)

 

I am using v1.0 as it I have provied the version number 1.0 in pom files as below

<api.version>1.0</api.version> (its in rs dir).

 

So can you please let know what might be the problem.

 

Regards,

Chethan 

VandewillySilva
Occasional Visitor

Re: REST API's display in RSdoc of Controller

I suppose the problem is with your javadoc. Note: It's important write your javadoc correctly. Eg: if the method has two arguments, you need to declare two @params inside the javadoc. The same is valid with return value and exceptions.
Could you send your method signature and your respective javadoc?

 

This sample works for me:

 

/**
* My method description here.
* <p/>
* Normal Response Code(s): ok (200)
* <p/>
* Error Response Codes: badRequest (400), unauthorized (401), forbidden
* (403), badMethod (405), serviceUnavailable (503), itemNotFound (404)
*
* @param myParam
* JSON representation of my object
* @return JSON object
* @throws JSONException
*/
@POST
@Path("somePathHere")
@Produces(MediaType.APPLICATION_JSON)
public Response myMethod(MyObject myParam)
throws JSONException {

return createResponseMessage("Success.");
}

Chethan_R
Occasional Advisor

Re: REST API's display in RSdoc of Controller

Hi,

 

Looks like I have followed similarly,

Please find my code below,

 

@Path("routers")
public class CurrentResources extends ControllerResource
{
    
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response list() {
        NetworkService service = get(NetworkService.class);
        List<Router> routers = service.getal();

        JsonService jsonService = get(JsonService.class);
        String json = jsonService.toJsonList(routers, Router.class, true);

        return ok(json).build();
    }

 

Note : I have mentioned @Path("routers") only at this place, Do I need to mention path value anywheare else apart from this or only this is fine.

 

Regards,

Chethan

VandewillySilva
Occasional Visitor

Re: REST API's display in RSdoc of Controller

Where is the javadoc? RSdoc takes the Javadoc to generate the REST API documentation.

/**
* Some important description here.
* <p/>
* Normal Response Code(s): ok (204)
* <p/>
* Error Response Codes: unauthorized (401), forbidden (403), badMethod
* (405), serviceUnavailable (503)
*
* @return Response the description for your method here
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response list() {
NetworkService service = get(NetworkService.class);
List<Router> routers = service.getal();

JsonService jsonService = get(JsonService.class);
String json = jsonService.toJsonList(routers, Router.class, true);

return ok(json).build();
}

Chethan_R
Occasional Advisor

Re: REST API's display in RSdoc of Controller

 

Hi,

 

Thanks for reply. I got my rest API working and the problem was with my curl command in which i missed my application name in command. The CMD is

 

  $ curl -sk -H "X-Auth-Token:577e4322e7a84d5f94f8a89696dd799a" https://x.x.x.x:8443/sdn/dr/v1.0/routers.

 

In above command i added my app name "dr" and it's working fine. Now My rest Api's are exposed and it is resolved.

 

But now i'm getting error  response from my REST API. Below is the error response  

 

CMD = $ curl -sk -H "X-Auth-Token:225bea05343847ba9e185ae8a88b26b7" https://x.x.x.x:8443/sdn/dr/v1.0/routers

 

Response = <html><head><title>Apache Tomcat/7.0.35 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.NullPointerException
com.mp.dr.rs.CurrentResources.List(CurrentResources.java:38)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
com.hp.util.rs.auth.AbstractTokenAuthFilter.doFilter(AbstractTokenAuthFilter.java:106)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.35 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.35</h3></body></html>

 

 

Please help me in resolving this issue.

 

Thankyou in advance