Hi all,

When I try to execute the following sample [1] service's POST operation I
could observe the bellow exception.

*java.lang.IllegalArgumentException: argument type mismatch*
* at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)*
* at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)*
* at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)*
* at java.lang.reflect.Method.invoke(Method.java:497)*
* at
org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:108)*
* at
org.wso2.msf4j.internal.MSF4JMessageProcessor.dispatchMethod(MSF4JMessageProcessor.java:129)*
* at
org.wso2.msf4j.internal.MSF4JMessageProcessor.receive(MSF4JMessageProcessor.java:73)*
* at
org.wso2.carbon.transport.http.netty.listener.WorkerPoolDispatchingSourceHandler$1.run(WorkerPoolDispatchingSourceHandler.java:127)*
* at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)*
* at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)*
* at java.lang.Thread.run(Thread.java:745)*

According to the sample service method I am going to capture the json
payload as an object passed to the method as follows.

@POST
@Path("/test")
public Response post(TestPayload testPayloadBody) {
    // TODO: Implementation for HTTP POST request
    System.out.println("POST invoked ====== " +testPayloadBody);
    return Response.ok().entity(testPayloadBody).build();
}


After further debugging the code, could find that the arguments list passed
at [2] contains a string. But according to the implementation it should be
a *TestPayload *object. If we observe at [3] the headers Map's keys are all
in lowercase. In order to get the header from the map, we use the constant
from* javax.ws.rs.core.Headers, *there the CONTENT_TYPE constant is not in
all lowercase and Due to this reason *contentTypeHeaderStr *becomes null
and leads to convert the object to a String by the default text formatter,
based on the wild card content-type [4].

[1]
https://drive.google.com/a/wso2.com/folderview?id=0Bx7aKS6MDJqSVDhVSTdWZ1JBVGc&usp=sharing
[2]
https://github.com/wso2/msf4j/blob/master/core/src/main/java/org/wso2/msf4j/internal/router/HttpMethodInfo.java#L108
[3]
https://github.com/wso2/carbon-messaging/blob/master/components/src/main/java/org/wso2/carbon/messaging/CarbonMessage.java#L162
[4]
https://github.com/wso2/msf4j/blob/master/core/src/main/java/org/wso2/msf4j/internal/router/HttpResourceModelProcessor.java#L158

Thanks,

*Nadeeshaan Gunasinghe*
Software Engineer, WSO2 Inc. http://wso2.com
+94770596754 | [email protected] | Skype: nadeeshaan.gunasinghe <#>
<http://www.facebook.com/nadeeshaan.gunasinghe>
<http://lk.linkedin.com/in/nadeeshaan>  <http://twitter.com/Nadeeshaan>
<http://nadeeshaan.blogspot.com/>
Get a signature like this: Click here!
<http://ws-promos.appspot.com/r?rdata=eyJydXJsIjogImh0dHA6Ly93d3cud2lzZXN0YW1wLmNvbS9lbWFpbC1pbnN0YWxsP3dzX25jaWQ9NjcyMjk0MDA4JnV0bV9zb3VyY2U9ZXh0ZW5zaW9uJnV0bV9tZWRpdW09ZW1haWwmdXRtX2NhbXBhaWduPXByb21vXzU3MzI1Njg1NDg3Njk3OTIiLCAiZSI6ICI1NzMyNTY4NTQ4NzY5NzkyIn0=&u=543026424429568>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to