【发布时间】:2014-07-31 18:23:20
【问题描述】:
@Path("/")
public class RestIntegration {
@GET
@Path("get/{id1}")
@Produces(MediaType.APPLICATION_JSON)
public String getOperation(@PathParam("id1")String id){
System.out.println("GET: Id from UI-->"+id);
return "Your Id is-->"+id;
}
@POST
@Path("/post/{id1}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response postOperation(@PathParam("id1")String id){
System.out.println("----INSIDE POST operation----"+id);
return Response.ok("Response from Mule Rest component").build();
}
}
骡流:
<flow name="restintegrationFlow1" doc:name="restintegrationFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="restint" doc:name="HTTP"/>
<jersey:resources doc:name="REST">
<component class="com.net.rest.RestIntegration"/>
</jersey:resources>
</flow>
使用 get 方法可以正常工作。 http://localhost:8081/restint/get/10.
当我通过http://localhost:8081/restint/post/22时,选择帖子类型并点击发送会出现以下错误:
ERROR 2014-07-31 11:18:43,337 [[restintegration].connector.http.mule.default.receiver.03] org.mule.exception.DefaultSystemExceptionStrategy:
********************************************************************************
Message : Failed to create MuleMessage
Code : MULE_ERROR-64
--------------------------------------------------------------------------------
Exception stack is:
1. String index out of range: -1 (java.lang.StringIndexOutOfBoundsException)
java.lang.String:1871 (null)
2. Failed to create MuleMessage (org.mule.api.lifecycle.CreateException)
org.mule.transport.AbstractTransportMessageHandler:462 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/lifecycle/CreateException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1871)
at org.mule.transport.http.multipart.MultiPartInputStream.parse(MultiPartInputStream.java:349)
at org.mule.transport.http.multipart.MultiPartInputStream.getParts(MultiPartInputStream.java:304)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
我使用 chrome rest 客户端来调用 url。在休息客户端中,我没有在 header 或 paload 中传递任何值。
【问题讨论】:
标签: java web-services rest mule