ERROR receivers.RPCInOnlyMessageReceiver:尝试调用服务方法placeOrder时发生异常

时间:2015-07-25 11:05:20

标签: wso2esb wso2is wso2carbon

我是" WSO2 ESB"的新手平台。我正在尝试从https://docs.wso2.com/display/ESB481/Sample+800%3A+Introduction+to+REST+API运行WSO2 ESB Rest API示例,所以我按照所有步骤进行操作

1)在一个终端上,我执行

C:\wso2esb-4.8.1\samples\axis2Server>axis2server.bat

2)在另一个终端上

C:\wso2esb-4.8.1\bin>wso2esb-samples.bat -sn 800

当我运行以下Rest URL时,它给了我错误。请帮助我知道为什么最后一个CURL命令没有提供所需的输出?

C:\>curl -v http://127.0.0.1:8280/stockquote/view/IBM
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8280 (#0)
> GET /stockquote/view/IBM HTTP/1.1
> User-Agent: curl/7.40.0
> Host: 127.0.0.1:8280
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/xml; charset=UTF-8
< Date: Sat, 25 Jul 2015 10:25:19 GMT
< Server: WSO2-PassThrough-HTTP
< Transfer-Encoding: chunked
<
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelop
e/"><soapenv:Body><ns:getQuoteResponse xmlns:ns="http://services.samples"><ns:return xmlns:ax21="http://servic
es.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:GetQuoteResponse"><ax21:c
hange>-2.6661865959844184</ax21:change><ax21:earnings>-9.163558543387456</ax21:earnings><ax21:high>193.7355458
031858</ax21:high><ax21:last>185.33888561996295</ax21:last><ax21:lastTradeTimestamp>Sat Jul 25 15:55:19 IST 20
15</ax21:lastTradeTimestamp><ax21:low>-181.04727326807318</ax21:low><ax21:marketCap>5.0117544767788365E7</ax21
:marketCap><ax21:name>IBM Company</ax21:name><ax21:open>-183.267380995112</ax21:open><ax21:peRatio>-19.7725282
3298653</ax21:peRatio><ax21:percentageChange>-1.3311819845208677</ax21:percentageChange><ax21:prevClose>200.28
716035727143</ax21:prevClose><ax21:symbol>IBM</ax21:symbol><ax21:volume>9220</ax21:volume></ns:return></ns:get
QuoteResponse></soapenv:Body></soapenv:Envelope>* Connection #0 to host 127.0.0.1 left intact

C:\>
C:\>curl -v http://127.0.0.1:8280/stockquote/view/MSFT
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8280 (#0)
> GET /stockquote/view/MSFT HTTP/1.1
> User-Agent: curl/7.40.0
> Host: 127.0.0.1:8280
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/xml; charset=UTF-8
< Date: Sat, 25 Jul 2015 10:27:52 GMT
< Server: WSO2-PassThrough-HTTP
< Transfer-Encoding: chunked
<
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelop
e/"><soapenv:Body><ns:getQuoteResponse xmlns:ns="http://services.samples"><ns:return xmlns:ax21="http://servic
es.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:GetQuoteResponse"><ax21:c
hange>-2.349071151386308</ax21:change><ax21:earnings>13.743507564027315</ax21:earnings><ax21:high>-71.04465262
35375</ax21:high><ax21:last>72.46275193434585</ax21:last><ax21:lastTradeTimestamp>Sat Jul 25 15:57:52 IST 2015
</ax21:lastTradeTimestamp><ax21:low>-72.22389056575905</ax21:low><ax21:marketCap>-6410999.83409811</ax21:marke
tCap><ax21:name>MSFT Company</ax21:name><ax21:open>-71.12518655378832</ax21:open><ax21:peRatio>23.786563750758
063</ax21:peRatio><ax21:percentageChange>-2.922305475406254</ax21:percentageChange><ax21:prevClose>80.38417513
691802</ax21:prevClose><ax21:symbol>MSFT</ax21:symbol><ax21:volume>8234</ax21:volume></ns:return></ns:getQuote
Response></soapenv:Body></soapenv:Envelope>* Connection #0 to host 127.0.0.1 left intact

C:\>curl -v -d @placeorder.xml -H "Content-type: application/xml" http://127.0.0.1:8280/stockquote/order/
Warning: Couldn't read data from file "placeorder.xml", this makes an empty
Warning: POST.
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8280 (#0)
> POST /stockquote/order/ HTTP/1.1
> User-Agent: curl/7.40.0
> Host: 127.0.0.1:8280
> Accept: */*
> Content-type: application/xml
> Content-Length: 0
>
< HTTP/1.1 202 Accepted
< Date: Sat, 25 Jul 2015 10:28:25 GMT
< Server: WSO2-PassThrough-HTTP
< Transfer-Encoding: chunked
<
* Connection #0 to host 127.0.0.1 left intact**

服务器日志:

15/07/25 15:53:57 INFO util.SampleAxis2ServerManager: [SimpleAxisServer] Started
Sat Jul 25 15:55:19 IST 2015 samples.services.SimpleStockQuoteService :: Generating quote for : IBM
Sat Jul 25 15:57:52 IST 2015 samples.services.SimpleStockQuoteService :: Generating quote for : MSFT
15/07/25 15:58:25 ERROR receivers.RPCInOnlyMessageReceiver: Exception occurred while trying to invoke service
method placeOrder
java.lang.IllegalArgumentException: wrong number of arguments
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:178)
        at org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceive
r.java:66)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:1
72)
        at org.apache.synapse.transport.nhttp.ServerWorker.processEntityEnclosingMethod(ServerWorker.java:459)

        at org.apache.synapse.transport.nhttp.ServerWorker.run(ServerWorker.java:279)
        at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
15/07/25 15:58:25 ERROR receivers.AbstractMessageReceiver: org.apache.axis2.AxisFault: Exception occurred whil
e trying to invoke service method placeOrder

Edit-1 :我在/wso2esb-4.8.1目录下创建了placeorder.xml文件。

C:\WSO2-ESB\wso2esb-4.8.1>curl -v -d @placeorder.xml -H "Content-type: application/xml
" http://127.0.0.1:8280/stockquote/order/
Warning: Couldn't read data from file "placeorder.xml", this makes an empty
Warning: POST.
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8280 (#0)
> POST /stockquote/order/ HTTP/1.1
> User-Agent: curl/7.40.0
> Host: 127.0.0.1:8280
> Accept: */*
> Content-type: application/xml
> Content-Length: 0
>
< HTTP/1.1 202 Accepted
< Date: Sat, 25 Jul 2015 17:35:56 GMT
< Server: WSO2-PassThrough-HTTP
< Transfer-Encoding: chunked
<
* Connection #0 to host 127.0.0.1 left intact

从链接中,似乎&#34; ESB将202响应返回给客户端&#34; 。这是对的吗?

1 个答案:

答案 0 :(得分:1)

  

ERROR receivers.RPCInOnlyMessageReceiver:发生异常时   试图调用服务方法placeOrder   java.lang.IllegalArgumentException:参数数量错误

在终端中运行以下命令时会发生上述错误。

  

curl -v -d @ placeorder.xml -H“Content-type:application / xml”   http://127.0.0.1:8280/stockquote/order/

您必须从您拥有placeorder.xml文件的目录运行上面的curl命令。你在同一目录中有placeorder.xml文件吗?如果没有,则必须从您具有placeorder.xml的目录运行命令,或者在运行上述curl命令时必须提供placeorder.xml文件的路径。

修改-1 您应该使用以下内容创建placeorder.xml文件并将其保存在您的计算机中。

<placeOrder xmlns="http://services.samples">
  <order>
     <price>50</price>
     <quantity>10</quantity>
     <symbol>IBM</symbol>
  </order>
</placeOrder>