【问题标题】:Error while implementing Rest API in wso2esb在 wso2esb 中实现 Rest API 时出错
【发布时间】:2014-05-14 13:53:40
【问题描述】:

我正在使用 wso2esb 4.7.0 和 wso2dss 3.1.0。我在 wso2dss 中使用以下配置创建了 restful 服务:

<query id="selectall" useConfig="default">
      <sql>select userid,username,password from usertable</sql>
      <result element="Entries" rowName="Entry">
         <element column="userid" name="userid" xsdType="string"/>
         <element column="username" name="username" xsdType="string"/>
         <element column="password" name="password" xsdType="string"/>
      </result>
   </query>

  <resource method="GET" path="user1">
      <call-query href="selectall"/>
   </resource>

使用以下 curl 命令在 dss 中运行良好

curl -X GET -H "Accept: application/json" http://192.168.1.23:9764/services/A_resttest.HTTPEndpoint/user1

现在我希望在 wso2esb 中使用此服务。如何在 esb 中访问此服务。为此我创建了一个端点:

Name: resttestendp
Address: http://192.168.1.23:9764/services/A_resttest.HTTPEndpoint
Format: GET

我的 esb 配置是这样的:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="RESTtest"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
      <log level="full"/>
         <send>
            <endpoint key="resttestendp"/>
         </send>
      </inSequence>
      <outSequence/>
   </target>
   <description/>
</proxy>

curl 用来访问它是:

curl -X GET -H "Accept: application/json" http://youtility-desktop:8282/services/RESTtest.HTTPEndpoint/user1

但它显示错误:

ERROR - NativeWorkerPool Uncaught exception
java.lang.NullPointerException
    at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:156)
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)

我应该在哪里进行更改或者我必须实现rest api概念?让我知道.. 我提到了:Access WSO2 Data Services Service via WSO2 ESB

【问题讨论】:

    标签: rest curl wso2 wso2esb wso2dss


    【解决方案1】:

    如果您需要在 ESB 中实现 REST API,则必须在 ESB 中创建 API。请使用以下链接获取更多帮助。

    一个样本: https://docs.wso2.org/display/ESB470/Sample+800%3A+Introduction+to+REST+API

    更多关于验证使用的帮助

    WSO2 ESB - REST API - Response Does Not Come

    一般:

    https://docs.wso2.org/display/ESB470/Getting+Started+with+REST+APIs

    【讨论】:

    • 嗨 jayalalk..感谢您的回复..我已经尝试过 docs.wso2.org/display/ESB470/… 但它也显示相同的错误,即服务器端的 NativeWorkerPool 未捕获异常 java.lang.NullPointerException
    • 首先,确保示例链接提供的示例工作正常。将 ESB 的新副本复制到新位置并使用命令启动 ESB。 "bin>wso2esb-samples.sh -sn 800" ,然后尝试使用 curl 访问 API。如果这可行,那么您就知道如何制作 API
    猜你喜欢
    • 2013-08-31
    • 1970-01-01
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-19
    相关资源
    最近更新 更多