【问题标题】:mule and rest with post method type骡子和休息后方法类型
【发布时间】: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


    【解决方案1】:

    找到解决方案,在 google chrome rest 客户端中,我没有在标题中选择内容类型。

    【讨论】:

      【解决方案2】:
       <http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration" basePath="restint"/>
      

      http://localhost:8081/restint/post/22 它对我有用-----INSIDE POST 操作----22- Mule Rest 组件的响应

      【讨论】:

      • 能否请您详细说明您的答案,添加更多关于您提供的解决方案的描述?
      猜你喜欢
      • 1970-01-01
      • 2013-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-12
      • 2016-09-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多