Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msf4j @RequestBody not working #553

Open
shalini1153 opened this issue Nov 27, 2018 · 1 comment
Open

msf4j @RequestBody not working #553

shalini1153 opened this issue Nov 27, 2018 · 1 comment

Comments

@shalini1153
Copy link

I am trying to write a post request and i am calling this request from angular 5 client

@OPTIONS
@POST
@Path("/post")
@Consumes("application/json")
@Produces("application/json")
public String addStock(@RequestBody JsonObject stock)
{
    
    return "test";
}

But everytime i call this request from angular i get this error

2018-11-27 18:36:09 WARN MSF4JHttpConnectorListener:243 - Unmapped exception
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.wso2.msf4j.internal.router.HttpMethodInfo.invokeResource(HttpMethodInfo.java:187)
at org.wso2.msf4j.internal.router.HttpMethodInfo.invoke(HttpMethodInfo.java:143)
at rg.wso2.msf4j.internal.MSF4JHttpConnectorListener.dispatchMethod(MSF4JHttpConnectorListener.java:218)
at org.wso2.msf4j.internal.MSF4JHttpConnectorListener.lambda$onMessage$39(MSF4JHttpConnectorListener.java:129)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Can anybody suggest on how to implement

@thusithathilina
Copy link
Contributor

thusithathilina commented Nov 27, 2018

RequestBody is not from the Jax-RS specification but from the spring implementation. AFAIK msf4j doesn't support that annotation. If you want to consume the whole message body you can use @Context Request and get the message content manually inside your resource. e.g. https://github.com/wso2/msf4j/blob/master/core/src/test/java/org/wso2/msf4j/service/TestMicroservice.java#L209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants