On Feb 27, 2013, at 3:37 AM, Jose María Zaragoza <[email protected]> wrote:
> We are creating a webservice (CXF-based) driven by a java class
> (Java2WS) with the following method:
>
> @WebMethod
> @RequestWrapper(className = "com.myproject.wrapper.MyRequestWrapper")
> @ResponseWrapper(className = "com.myproject.wrapper.MyResponseWrapper")
> public MyResponse verifyCode(@WebParam(name = "code") String code) {
> ...
> return new MyResponse("Hello",StatusEnum.okay);
> }
>
> I use the wrappers to define the elements of the request resp.
> response in more detail: the correct element names (which start with
> an uppercase character), required and optional elements, ...). But I
> am not sure if this is the right way to do it (there is no in-depth
> documentation about wrappers, isn't it?)
The wrappers would need to have getter/setter methods for the actual
return/request parameters. In your case, the ResponseWrapper would need to
have methods like "void setReturn(MyResponse)" andy the RequestWrapper would
need a "String getCode()" method.
Dan
> The class MyResponse:
>
> public class MyResponseWrapper {
>
> private String result;
> private ModeEnum status;
>
> // getters and setters
> }
> The class MyReponseWrapper
>
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "myResponse")
> public class MyResponseWrapper {
>
> @XmlElement(name="Result")
> private String result;
>
> @XmlElement(name = "Status")
> private StatusEnum status;
>
> public MyResponseWrapper() {
> result="fu"; // just for testing
> }
>
> // getters and setters
> }
>
> Currently I don't understand the Wrappers. When I return an instance
> of MyReponse, how does the data from MyResponse be injected into
> MyResponseWrapper respectivly to the SOAP body of the response?
>
> By testing this webservice I can see that an instance of
> MyResponseWrapper is instantiated and the SOAP body contains the
> correct elements but with default data (for example: result="fu"
> instead of "Hello"). I expected that CXF injects matching data from
> MyResponse to MyResponseWrapper. Is that wrong?
>
> If this is the wrong way to do it: Wat is the right way to specify the
> resulting SOAP xml when using Java2WS?
>
> By the way: The above source snippets are just examples taken from our
> more complex (more fields) classes.
>
>
> Thanks and best regards
--
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com