The ONLY way I can see to do this is to create a wrapper bean for the 
findProducts method and add an @XmlElementWrapper annotation to the field.  
It's a shame that that annotation isn't allowed on a parameter so we could map 
it in when we build the wrapper types internally.    Just checked JAXB 2.2 and 
it's not allowed on the param there either.  :-(

Probably the easiest way to get going is to run:
java2ws -wrapperbean ......

to produce the wrapper beans and copy the request bean into your project and 
modify it.   You'll need to add the @RequestWrapper annotation to your method 
to pick it up.

Dan


On Thu March 26 2009 12:20:05 pm MagnusEd wrote:
> Hi all. I am having trouble defining my WebService as I want it.
>
> Below is a sample how I want the XML to look like when I send it:
>
> <com:findProducts>
>       <catalog>myCatalog</catalog>
>       <attributes>
>               <attribute>
>                       <name>?</name>
>                       <value>?</value>
>               </attribute>
>               <attribute>
>                       <name>?</name>
>                       <value>?</value>
>               </attributes>
>       </attributes>
> </com:findProducts>
>
> But after generating from my annotated Java files, I get a contract that
> defines the XML like the following:
>
> <com:findProducts>
>       <catalog>myCatalog</catalog>
>       <attributes>
>               <name>?</name>
>               <value>?</value>
>       </attributes>
>       <attributes>
>               <name>?</name>
>               <value>?</value>
>       </attributes>
> </com:findProducts>
>
>
> The important Java files are as follows:
>
> @WebService(targetNamespace = ".....")
> public interface ProductService
> {
>       public ProductListBean findProducts(
>                       @WebParam(name = "catalog") String catalog,
>                       @WebParam(name = "attributes") 
> List<AttributeNameValueBean> attributes);
>
> and
>
> @XmlRootElement(name = "attribute")
> public class AttributeNameValueBean
> {
>       private String name;
>       private String value;
>
>       @XmlElement(name = "name",required=true)
>       public String getName()
>       {
>               return name;
>       }
>
>
> I thought that defining the list as "attributes" and the
> AttributeNameValueBean as "attribute" would get me what I want. But
> apparently not. Anybody got an idea of how to do it differently?
>
> Regards,
> Magnus

-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to