I am using restEasy(Restful implementation for jboss) ejb3.0, Jboss5.1.1 AS
I did restful service which accepting simple object.
this is at the server side:
@POST
@Path("testObjects")
@Consumes("application/xml")
@Produces("text/plain")
public String testObjects(GrandSun sun)
{
System.out.println(sun.toString());
return "success";
}
this is the object which I have declared at the server side:
package com.mirs.wma.web.data;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class GrandSun
{
int m = 1;
int g = 2;
}
I test it via restfull client which sending xml string and it works fine.
<?xml version="1.0" encoding="UTF-8"?>
<grandSun>
<m>111</m>
<g>22</g>
</grandSun>
What I a开发者_StackOverflowm looking for is a restful client which will be able to send the whole object (as is) without needing me to convert manually to xml format.
Is there any option to do it via annotation?
I will just need to annotate the object at the client side and send it as is to the restful service?
thanks, ray.
thanks, ray.
Using RestEasy own client, along with a JAXB marshaller (I prefer Jackson but jettison comes stock with RestEasy I think). While on the server side POJOs are unmarshalled, the client side is responsible for marshalling the POJO.
Hope this gives you a few hints.
Most IDEs can generate a WebService client-stub from a WSDL. This will provide the infrastructure needed to convert objects automatically into XML requests and deserialize the result.
Failing that, check out wsdl2java. It will generate the stubs for you.
精彩评论