You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tapdur <ta...@gmail.com> on 2010/02/11 02:17:18 UTC

xsd, unmarshal and getBody

Hi 

i doin't understand why it fail :
i have an xsd file
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
	<xsd:complexType name="PersonType">
        <xsd:sequence>
            <xsd:element name="firstName" type="xsd:string"/>
            <xsd:element name="lastName" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="Person" type="PersonType"/>		

 			
		<xsd:complexType name="GreetingRequestType">
				<xsd:sequence>
					<xsd:element name="name" type="xsd:string" />
				</xsd:sequence>	
		</xsd:complexType>

	<xsd:element name="GreetingRequest" type="GreetingRequestType"/>		
	
	<xsd:complexType name="GreetingResponseType">
		<xsd:sequence>
			<xsd:element name="welcome" type="xsd:string" />
		</xsd:sequence>
	</xsd:complexType>
	<xsd:element name="GreetingResponse" type="GreetingResponseType"/>
</xsd:schema>


i use xjc to produce the java file


i have this route
	  <route>
	    <from
uri="restlet:http://127.0.0.1:9090/greeting?restletMethods=POST,GET"/>
	    	<unmarshal>
	    	        	<jaxb ignoreJAXBElement="false" prettyPrint="true"
contextPath="poc.camel.echange"/>
        	</unmarshal>

	    	<process ref="greeting"></process>
			<marshal>
            	<jaxb ignoreJAXBElement="false" prettyPrint="true"
contextPath="poc.camel.echange" />
        	</marshal>
	  </route>

This process failed
   public void process(Exchange exchange) throws Exception {
      GreetingRequestType user = (GreetingRequestType)
exchange.getIn().getBody(GreetingRequestType.class);


// 

        GreetingResponseType gr = new GreetingResponseType();
         gr.setWelcome(user.getName());
        exchange.getOut().setBody( gr );
}

the user is always nill, how to retrieve the instance ? (present in the
echange value see in debug mode)


but not this one
   public void process(Exchange exchange) throws Exception {
// nothing
    }
the incoming request is well unmarshall and marshall in the response
why ?


Thx
Bruno
-- 
View this message in context: http://old.nabble.com/xsd%2C-unmarshal-and-getBody-tp27540894p27540894.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: xsd, unmarshal and getBody

Posted by Willem Jiang <wi...@gmail.com>.
Can you take a look at the camel jaxb unit tests[1]?
I don't how can you set the response object by change the greeting 
processor to be empty process.

BTW, you didn't mention the camel version.

[1] 
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/CamelJaxbTest.java

Willem

Tapdur wrote:
> Hi 
> 
> i doin't understand why it fail :
> i have an xsd file
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
> 	<xsd:complexType name="PersonType">
>         <xsd:sequence>
>             <xsd:element name="firstName" type="xsd:string"/>
>             <xsd:element name="lastName" type="xsd:string"/>
>         </xsd:sequence>
>     </xsd:complexType>
>     <xsd:element name="Person" type="PersonType"/>		
> 
>  			
> 		<xsd:complexType name="GreetingRequestType">
> 				<xsd:sequence>
> 					<xsd:element name="name" type="xsd:string" />
> 				</xsd:sequence>	
> 		</xsd:complexType>
> 
> 	<xsd:element name="GreetingRequest" type="GreetingRequestType"/>		
> 	
> 	<xsd:complexType name="GreetingResponseType">
> 		<xsd:sequence>
> 			<xsd:element name="welcome" type="xsd:string" />
> 		</xsd:sequence>
> 	</xsd:complexType>
> 	<xsd:element name="GreetingResponse" type="GreetingResponseType"/>
> </xsd:schema>
> 
> 
> i use xjc to produce the java file
> 
> 
> i have this route
> 	  <route>
> 	    <from
> uri="restlet:http://127.0.0.1:9090/greeting?restletMethods=POST,GET"/>
> 	    	<unmarshal>
> 	    	        	<jaxb ignoreJAXBElement="false" prettyPrint="true"
> contextPath="poc.camel.echange"/>
>         	</unmarshal>
> 
> 	    	<process ref="greeting"></process>
> 			<marshal>
>             	<jaxb ignoreJAXBElement="false" prettyPrint="true"
> contextPath="poc.camel.echange" />
>         	</marshal>
> 	  </route>
> 
> This process failed
>    public void process(Exchange exchange) throws Exception {
>       GreetingRequestType user = (GreetingRequestType)
> exchange.getIn().getBody(GreetingRequestType.class);
> 
> 
> // 
> 
>         GreetingResponseType gr = new GreetingResponseType();
>          gr.setWelcome(user.getName());
>         exchange.getOut().setBody( gr );
> }
> 
> the user is always nill, how to retrieve the instance ? (present in the
> echange value see in debug mode)
> 
> 
> but not this one
>    public void process(Exchange exchange) throws Exception {
> // nothing
>     }
> the incoming request is well unmarshall and marshall in the response
> why ?
> 
> 
> Thx
> Bruno