You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2007/12/01 00:01:24 UTC

Re: problem with xml element for response with common service for SOAP and XML

This is getting into some complex JAXB things.  Probably best for the 
JAXB lists.

That said, looking at it, I THINK you want to replace:
@XmlAnyElement
with:
@javax.xml.bind.annotation.XmlElementRef(name = "Data") 

The XmlAnyElement thing is put where you want the schema to have 
a "xsd:any" which I don't think is what you want there.

I think you want it to point to the Data element as the base type for the 
element.

Dan



On Tuesday 27 November 2007, mule1 wrote:
> Hello,
>
> I am little bit stuck and need to get this working for a release and
> not sure what I am doing wrong to expose same service class for both
> SOAP and XML messaging. I am having problem with some annotations for
> XmlElement for an Array property on my response object class. If I
> annotate the Array property as "
> @XmlElementWrapper(name="Data") @XmlAnyElement", the XML messaging
> works fine returning me the correct response xml, however, with my
> SOAP messaging, the response returns but without binding my response
> data from the array property.
>
> What I have is - I have a SEI class defined that I have configured to
> expose my url as both SOAP (e.g at url /soapurl) and XML (e.g at url
> /xmlurl) using jaxb/jaxws. My SEI method and the related response
> class are as follow: <code>
> @WebService
> public interface CustomerWebService {
>
>    @WebResult(name="CustResponse")
>    public DataExchange findCustomer(Customer cust);
> }
>
> @XmlRootElement(name = "Customer")
> public class Customer extends Data {
>    String name;
>
>    String address;
> }
>
> @XmlRootElement(name = "DataExchange")
> public class DataExchange {
>
> private Customer[] custs;
>
> @XmlElementWrapper(name="Data") @XmlAnyElement
> private Customer[] getCusts() {
>
> }
>
> </code>
>
>
> If I see in tcpmon my request/response for SOAP, I do see that the
> SOAP message has the data content for property custs (of class
> Customer), but in the final xml, the element
> <Data><Customer>.....</Customer></Data> doesn't show up. The xml
> response for XML messaging is just fine with correct data.
>
> What do I need to do to have the SOAP message response work with
> having the XmlElement annotation still there for the Array property?
>
> Thanks.



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog