Topic
  • 9 replies
  • Latest Post - ‏2013-11-19T09:25:19Z by filip_matosic
filip_matosic
filip_matosic
22 Posts

Pinned topic Simple EGL REST Service

‏2013-11-14T12:36:30Z |

I am using RBD 8.1 Was 7

and have been searching on the web trying to find steps to create a simple EGL REST service (found SOAP solutions)

which i can access through javascript XMLHttpRequest or jquery .

i would be very grateful if anyone can point me in the right direcion. 

  • filip_matosic
    filip_matosic
    22 Posts
    ACCEPTED ANSWER

    Re: Simple EGL REST Service

    ‏2013-11-19T09:25:19Z  

    I belive the URL is OK  as the request hits the restservices servlet, but seems the restservices servlet

    does not use the JSON-RPC {"bindingName":"myservice","method":"tocall","params":[],"id":1}; but the URL portion

    to locate the service.

    Looking at the link JBASkeen posted it should. Guess i missed something to expose my service to the restservices servlet.

    So what has to be done to make restservices servlet aware of my service?

     

     

    I found what I was missing, RBD did not create service mappings inside the -uri.xml located in the EGLGen\JavaSource:

    eg.

     <servicemapping classname="services.myservice">
        <uri httpmethod="POST" in-encoding="JSON" out-encoding="JSON">/myservice</uri>
      </servicemapping>

    after adding works fine.

    Thanks all for help.

    Updated on 2013-11-19T09:25:38Z at 2013-11-19T09:25:38Z by filip_matosic
  • Ortwin
    Ortwin
    208 Posts

    Re: Simple EGL REST Service

    ‏2013-11-14T16:33:07Z  

    Hi Filip,

     

    In RBD there is a wizard to generate services from PCML. PCML is used for Program Calls.

    In RBD there is also a wizard (Data Access Application wizard) to generate services using SQL.

    You also can create your own service without using a wizard.

    The attached powerpoint describes the last.

     

    Ortwin

    Attachments

  • filip_matosic
    filip_matosic
    22 Posts

    Re: Simple EGL REST Service

    ‏2013-11-15T08:08:47Z  
    • Ortwin
    • ‏2013-11-14T16:33:07Z

    Hi Filip,

     

    In RBD there is a wizard to generate services from PCML. PCML is used for Program Calls.

    In RBD there is also a wizard (Data Access Application wizard) to generate services using SQL.

    You also can create your own service without using a wizard.

    The attached powerpoint describes the last.

     

    Ortwin

    Ortwin, thank you for your reply,

    I have looked into the ppt you posted but it only explains how to call the service from RUI not from javascript which i am trying to accomplish.

    What I am trying to find is, when i create the service what is the URL of the service which I am trying to access .

    Taking the ppt in consideration i would guess I would be doing as follows:

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET","http://localhost:8080/EGLWeb/restservices/RUIRestServices",true);
    xmlhttp.send();

    but then i get error, console log follows:

    E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[restservices]: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: SRVE0295E: Error reported: 500
    at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:637)
    at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1180)
    at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1162)
    at com.ibm.javart.services.RestServiceServlet.write(RestServiceServlet.java:277)
    at com.ibm.javart.services.RestServiceServlet.doHttp(RestServiceServlet.java:187)
    at com.ibm.javart.services.RestServiceServlet.doPost(RestServiceServlet.java:104)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
     

     

     

  • Ortwin
    Ortwin
    208 Posts

    Re: Simple EGL REST Service

    ‏2013-11-15T20:06:14Z  

    Ortwin, thank you for your reply,

    I have looked into the ppt you posted but it only explains how to call the service from RUI not from javascript which i am trying to accomplish.

    What I am trying to find is, when i create the service what is the URL of the service which I am trying to access .

    Taking the ppt in consideration i would guess I would be doing as follows:

    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET","http://localhost:8080/EGLWeb/restservices/RUIRestServices",true);
    xmlhttp.send();

    but then i get error, console log follows:

    E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[restservices]: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: SRVE0295E: Error reported: 500
    at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:637)
    at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1180)
    at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1162)
    at com.ibm.javart.services.RestServiceServlet.write(RestServiceServlet.java:277)
    at com.ibm.javart.services.RestServiceServlet.doHttp(RestServiceServlet.java:187)
    at com.ibm.javart.services.RestServiceServlet.doPost(RestServiceServlet.java:104)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
     

     

     

    Ah, I did overlook the part that you require the service to be called from outside EGL.

    And frankly I'm not sure if that is possible because EGL generates a RESTful service and not a genuine REST service supporting get, post, put and delete methodes. When we create services that have to be accessable by third parties we choose SOAP services.

    I hope s.o. else can give more valuable advise on creating real REST services using EGL.

     

    Ortwin

  • JBASkeen
    JBASkeen
    137 Posts

    Re: Simple EGL REST Service

    ‏2013-11-15T22:07:24Z  

    Hello,

    Recently I had this same requirement and got it working with the help from the following post/link. I am currently calling EGL REST-RPC services from Worklight Adapters which use JavaScript. In the link provided Dan Darnell shows an example of using JS to format the request correctly. The issue is that you have to format the JS/AJAX request body/header in a way that the EGL servlet is expecting providing appropriate values. Been working well for me so far.

    https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014580713

    James

  • filip_matosic
    filip_matosic
    22 Posts

    Re: Simple EGL REST Service

    ‏2013-11-18T09:22:02Z  

    After some playing around i got a different error in my log (although the first error is still just before the new one):

     
    [18.11.13. 10:18:02:711 CET] 00000022 SystemErr     R No JSON? bindingName=findme&method=functionName&params=
    [18.11.13. 10:18:02:711 CET] 00000022 SystemErr     R com.ibm.javart.json.TokenMgrError: Lexical error at line 1, column 1.  Encountered: "b" (98), after : ""
    [18.11.13. 10:18:02:711 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParserTokenManager.getNextToken(JsonParserTokenManager.java:544)
    [18.11.13. 10:18:02:712 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.jj_consume_token(JsonParser.java:283)
    [18.11.13. 10:18:02:712 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.Object(JsonParser.java:64)
    [18.11.13. 10:18:02:712 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.ObjectParse(JsonParser.java:56)
    [18.11.13. 10:18:02:717 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.parse(JsonParser.java:46)
    [18.11.13. 10:18:02:720 CET] 00000022 SystemErr     R  at com.ibm.javart.services.HttpRequest.create(HttpRequest.java:113)
    [18.11.13. 10:18:02:720 CET] 00000022 SystemErr     R  at com.ibm.javart.services.HttpRequest.create(HttpRequest.java:104)
    [18.11.13. 10:18:02:722 CET] 00000022 SystemErr     R  at com.ibm.javart.services.RestServiceServlet.doHttp(RestServiceServlet.java:171)
    [18.11.13. 10:18:02:723 CET] 00000022 SystemErr     R  at com.ibm.javart.services.RestServiceServlet.doPost(RestServiceServlet.java:104)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)
    [18.11.13. 10:18:02:729 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
    [18.11.13. 10:18:02:730 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    [18.11.13. 10:18:02:730 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
    [18.11.13. 10:18:02:730 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    [18.11.13. 10:18:02:732 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
    [18.11.13. 10:18:02:732 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    [18.11.13. 10:18:02:733 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
    [18.11.13. 10:18:02:743 CET] 00000022 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    [18.11.13. 10:18:02:745 CET] 00000022 SystemErr     R  at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    [18.11.13. 10:18:02:752 CET] 00000022 SystemErr     R  at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    [18.11.13. 10:18:02:757 CET] 00000022 SystemErr     R  at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    [18.11.13. 10:18:02:757 CET] 00000022 SystemErr     R  at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    [18.11.13. 10:18:02:757 CET] 00000022 SystemErr     R  at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    [18.11.13. 10:18:02:758 CET] 00000022 SystemErr     R  at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    [18.11.13. 10:18:02:758 CET] 00000022 SystemErr     R  at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)

     

    I can se its something to do with my json params, seems it cannot parse to JSON, anybody have any idea?

  • filip_matosic
    filip_matosic
    22 Posts

    Re: Simple EGL REST Service

    ‏2013-11-18T11:59:01Z  

    After some playing around i got a different error in my log (although the first error is still just before the new one):

     
    [18.11.13. 10:18:02:711 CET] 00000022 SystemErr     R No JSON? bindingName=findme&method=functionName&params=
    [18.11.13. 10:18:02:711 CET] 00000022 SystemErr     R com.ibm.javart.json.TokenMgrError: Lexical error at line 1, column 1.  Encountered: "b" (98), after : ""
    [18.11.13. 10:18:02:711 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParserTokenManager.getNextToken(JsonParserTokenManager.java:544)
    [18.11.13. 10:18:02:712 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.jj_consume_token(JsonParser.java:283)
    [18.11.13. 10:18:02:712 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.Object(JsonParser.java:64)
    [18.11.13. 10:18:02:712 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.ObjectParse(JsonParser.java:56)
    [18.11.13. 10:18:02:717 CET] 00000022 SystemErr     R  at com.ibm.javart.json.JsonParser.parse(JsonParser.java:46)
    [18.11.13. 10:18:02:720 CET] 00000022 SystemErr     R  at com.ibm.javart.services.HttpRequest.create(HttpRequest.java:113)
    [18.11.13. 10:18:02:720 CET] 00000022 SystemErr     R  at com.ibm.javart.services.HttpRequest.create(HttpRequest.java:104)
    [18.11.13. 10:18:02:722 CET] 00000022 SystemErr     R  at com.ibm.javart.services.RestServiceServlet.doHttp(RestServiceServlet.java:171)
    [18.11.13. 10:18:02:723 CET] 00000022 SystemErr     R  at com.ibm.javart.services.RestServiceServlet.doPost(RestServiceServlet.java:104)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
    [18.11.13. 10:18:02:728 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:937)
    [18.11.13. 10:18:02:729 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
    [18.11.13. 10:18:02:730 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    [18.11.13. 10:18:02:730 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
    [18.11.13. 10:18:02:730 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    [18.11.13. 10:18:02:732 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
    [18.11.13. 10:18:02:732 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    [18.11.13. 10:18:02:733 CET] 00000022 SystemErr     R  at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
    [18.11.13. 10:18:02:743 CET] 00000022 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    [18.11.13. 10:18:02:744 CET] 00000022 SystemErr     R  at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    [18.11.13. 10:18:02:745 CET] 00000022 SystemErr     R  at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    [18.11.13. 10:18:02:752 CET] 00000022 SystemErr     R  at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    [18.11.13. 10:18:02:757 CET] 00000022 SystemErr     R  at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    [18.11.13. 10:18:02:757 CET] 00000022 SystemErr     R  at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    [18.11.13. 10:18:02:757 CET] 00000022 SystemErr     R  at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    [18.11.13. 10:18:02:758 CET] 00000022 SystemErr     R  at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    [18.11.13. 10:18:02:758 CET] 00000022 SystemErr     R  at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)

     

    I can se its something to do with my json params, seems it cannot parse to JSON, anybody have any idea?

    The above problem is the JSON that was not properly send. Now i get to read the response from the server and got:

    {"error" : 
    {"name" : "JSONRPCError", "code" : "EGL1543E", "message" : "EGL1543E No REST-RPC service was found. URL:\/findme\/restservices\/myservice\nEGL0001I The error occurred in EGL REST Service servlet.", 
    "error" : 
    {"messageID" : "EGL1543E", "message" : "EGL1543E No REST-RPC service was found. URL:\/findme\/restservices\/myservice\nEGL0001I The error occurred in EGL REST Service servlet.", "source" : 2, "detail1" : "500", "detail2" : "FAILED", "detail3" : "", "name" : "egl.core.ServiceInvocationException"}}} 

    I have created a service inside EGLSource->services named myservice.egl in which I have a method to call
    Inside egldd added service deployment as described:

    <?xml version="1.0" encoding="UTF-8"?>
    <egl:deployment xmlns:egl="http://www.ibm.com/xmlns/egl/deployment/7.0">
      <bindings>
        <restBinding baseURI="http://localhost:9080/findme/restservices/myservice" enableGeneration="true" name="myservice" preserveRequestHeaders="false"/>
      </bindings>
      <restservices>
        <restservice enableGeneration="true" implementation="services.myservice" stateful="true" uri="myservice"/>
      </restservices>
      <egl:target.project name="findme"/>
    </egl:deployment>

    This is the code I uset to send the reques:

     var data = {"bindingName":"myservice","method":"tocall","params":[],"id":1};

    $.ajax({
     type: "POST",
      dataType: "json",
      contentType :"application/json",
     url: "http://localhost:9080/findme/restservices/myservice/",
     data: JSON.stringify(data)
     
    })
     .done(function( msg ) {
       alert( "Data Saved: " + msg );
     }).error(function(xhr, ajaxOptions, thrownError){
     
      console.log(decodeURIComponent(xhr.getResponseHeader('JSONRPCError')));
       alert( "Error: " + decodeURIComponent(xhr.getResponseHeader('JSONRPCError') ));
     });

    Any suggestions?

    Updated on 2013-11-18T12:12:12Z at 2013-11-18T12:12:12Z by filip_matosic
  • markevans
    markevans
    3034 Posts

    Re: Simple EGL REST Service

    ‏2013-11-18T12:40:27Z  

    The above problem is the JSON that was not properly send. Now i get to read the response from the server and got:

    {"error" : 
    {"name" : "JSONRPCError", "code" : "EGL1543E", "message" : "EGL1543E No REST-RPC service was found. URL:\/findme\/restservices\/myservice\nEGL0001I The error occurred in EGL REST Service servlet.", 
    "error" : 
    {"messageID" : "EGL1543E", "message" : "EGL1543E No REST-RPC service was found. URL:\/findme\/restservices\/myservice\nEGL0001I The error occurred in EGL REST Service servlet.", "source" : 2, "detail1" : "500", "detail2" : "FAILED", "detail3" : "", "name" : "egl.core.ServiceInvocationException"}}} 

    I have created a service inside EGLSource->services named myservice.egl in which I have a method to call
    Inside egldd added service deployment as described:

    <?xml version="1.0" encoding="UTF-8"?>
    <egl:deployment xmlns:egl="http://www.ibm.com/xmlns/egl/deployment/7.0">
      <bindings>
        <restBinding baseURI="http://localhost:9080/findme/restservices/myservice" enableGeneration="true" name="myservice" preserveRequestHeaders="false"/>
      </bindings>
      <restservices>
        <restservice enableGeneration="true" implementation="services.myservice" stateful="true" uri="myservice"/>
      </restservices>
      <egl:target.project name="findme"/>
    </egl:deployment>

    This is the code I uset to send the reques:

     var data = {"bindingName":"myservice","method":"tocall","params":[],"id":1};

    $.ajax({
     type: "POST",
      dataType: "json",
      contentType :"application/json",
     url: "http://localhost:9080/findme/restservices/myservice/",
     data: JSON.stringify(data)
     
    })
     .done(function( msg ) {
       alert( "Data Saved: " + msg );
     }).error(function(xhr, ajaxOptions, thrownError){
     
      console.log(decodeURIComponent(xhr.getResponseHeader('JSONRPCError')));
       alert( "Error: " + decodeURIComponent(xhr.getResponseHeader('JSONRPCError') ));
     });

    Any suggestions?

    Hi,

    I am not sure this is causing the issue, but the URL looks to be formed wrong:

    URL:\/findme\/restservices\/myservice

    Notice it has a forward and backward slash "\/" for each separator.  

    You might want to try specifying the URL in a different way like a double backslash ("\\") or a single backslash instead of forward slash ("\").

    Others may have any idea as well.

     

     

  • filip_matosic
    filip_matosic
    22 Posts

    Re: Simple EGL REST Service

    ‏2013-11-18T13:40:47Z  
    • markevans
    • ‏2013-11-18T12:40:27Z

    Hi,

    I am not sure this is causing the issue, but the URL looks to be formed wrong:

    URL:\/findme\/restservices\/myservice

    Notice it has a forward and backward slash "\/" for each separator.  

    You might want to try specifying the URL in a different way like a double backslash ("\\") or a single backslash instead of forward slash ("\").

    Others may have any idea as well.

     

     

    I belive the URL is OK  as the request hits the restservices servlet, but seems the restservices servlet

    does not use the JSON-RPC {"bindingName":"myservice","method":"tocall","params":[],"id":1}; but the URL portion

    to locate the service.

    Looking at the link JBASkeen posted it should. Guess i missed something to expose my service to the restservices servlet.

    So what has to be done to make restservices servlet aware of my service?

     

     

  • filip_matosic
    filip_matosic
    22 Posts

    Re: Simple EGL REST Service

    ‏2013-11-19T09:25:19Z  

    I belive the URL is OK  as the request hits the restservices servlet, but seems the restservices servlet

    does not use the JSON-RPC {"bindingName":"myservice","method":"tocall","params":[],"id":1}; but the URL portion

    to locate the service.

    Looking at the link JBASkeen posted it should. Guess i missed something to expose my service to the restservices servlet.

    So what has to be done to make restservices servlet aware of my service?

     

     

    I found what I was missing, RBD did not create service mappings inside the -uri.xml located in the EGLGen\JavaSource:

    eg.

     <servicemapping classname="services.myservice">
        <uri httpmethod="POST" in-encoding="JSON" out-encoding="JSON">/myservice</uri>
      </servicemapping>

    after adding works fine.

    Thanks all for help.

    Updated on 2013-11-19T09:25:38Z at 2013-11-19T09:25:38Z by filip_matosic