You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Steven Haines <ly...@yahoo.com> on 2010/02/12 21:34:39 UTC

XmlBeans and Spring RestTemplate

Hi,

I'm trying to use XmlBeans as a marshaller/unmarshaller for Spring's RestTemplate for an XML document that does not specify an XSD in its header. I constructed the XSD and used the XmlBeans Maven task the generate code from it, but I'm not sure how to tell XmlBeans what classes to unmarshall the document to. 

I found an example using JAXB2 to accomplish the same objective (reading twitter web services from a manually created XSD): 

http://aruld.info/resttemplate-the-spring-way-of-accessing-restful-services/

The Jaxb2Marshaller has a "classesToBeBound" property:
    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="classesToBeBound">
           <list>
                <value>twitter.model.Statuses</value>
            </list>
        </property>
    </bean>

I did not see anything similar in the XmlBeansMarshaller (unless there is a way to specify class mappings in an XmlOptions object.) Does anyone have experience with Spring's XmlBeansMarshaller (http://static.springsource.org/spring/docs/3.0.0.RELEASE/javadoc-api/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.html) that might be able to point me in the right direction?

Thanks
Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: XmlBeans and Spring RestTemplate

Posted by Jacob Danner <ja...@gmail.com>.
Have you looked into using an xsdconfig file? I know you can do class
mappings from that if its needed.

I'm not familiar with Spring's RestTemplate.
Did you use XmlBeans' inst2xsd tool to generate a schema for you?

Usually the best way to find the class to marshal to when starting
from an instance is to  look for a class named ???Document where ???
== the name of the instance's root element.

HTH,
-jacobd


On Fri, Feb 12, 2010 at 12:34 PM, Steven Haines <ly...@yahoo.com> wrote:
> Hi,
>
> I'm trying to use XmlBeans as a marshaller/unmarshaller for Spring's RestTemplate for an XML document that does not specify an XSD in its header. I constructed the XSD and used the XmlBeans Maven task the generate code from it, but I'm not sure how to tell XmlBeans what classes to unmarshall the document to.
>
> I found an example using JAXB2 to accomplish the same objective (reading twitter web services from a manually created XSD):
>
> http://aruld.info/resttemplate-the-spring-way-of-accessing-restful-services/
>
> The Jaxb2Marshaller has a "classesToBeBound" property:
>    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
>        <property name="classesToBeBound">
>           <list>
>                <value>twitter.model.Statuses</value>
>            </list>
>        </property>
>    </bean>
>
> I did not see anything similar in the XmlBeansMarshaller (unless there is a way to specify class mappings in an XmlOptions object.) Does anyone have experience with Spring's XmlBeansMarshaller (http://static.springsource.org/spring/docs/3.0.0.RELEASE/javadoc-api/org/springframework/oxm/xmlbeans/XmlBeansMarshaller.html) that might be able to point me in the right direction?
>
> Thanks
> Steve
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org