You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hutao722 <hu...@163.com> on 2013/09/29 07:56:41 UTC

splitting xml failed when running on tomcat

Hi,

i wish to split the big xml to the small one. So I tried to use tokenizeXML
or Stax method to implement it. The two ways both work when i did the unit
test. But when i deployed the war to Tomcat. I found they both failed to
split the xml. It seems when split failed, the following process handler is
skipped and the entire xml will be response to the the browser. I didn't
find any errors in tomcat or in my browser. The code is:


JaxbDataFormat jaxb = new JaxbDataFormat(false);
jaxb.setContextPath(GetDetailInfoByTrainCode.class.getPackage().getName());
			
from("restlet:/pacs/{trainCode}?restletMethods=post,get")
.process(new Processor() {
	public void process(Exchange exchange) throws Exception {
		String trainCode = exchange.getIn().getHeader("trainCode", String.class);
		GetDetailInfoByTrainCode gd = new GetDetailInfoByTrainCode();
		gd.setTrainCode(trainCode);
		gd.setUserID("");
		exchange.getIn().setBody(gd, GetDetailInfoByTrainCode.class);
	}
})
.marshal(jaxb)
.to("spring-ws:http://www.webxml.com.cn/WebServices/TrainTimeWebService.asmx?soapAction=http://WebXml.com.cn/getDetailInfoByTrainCode")
.split().tokenizeXML("getDetailInfo").streaming()
// or using stax 	
//.split(StAXBuilder.stax(GetDetailInfo.class, true)).streaming()
.process(new Processor() {
	@Override
	public void process(Exchange exchange) throws Exception {					
		String content = exchange.getIn().getBody(String.class);
		Response response =
exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE,
Response.class);
		response.setStatus(Status.SUCCESS_OK);
		response.setEntity(content, MediaType.TEXT_XML);
		exchange.getOut().setBody(response);
	}
});   

Why? Do i need to do something when running on Tomcat?

Thanks!




--
View this message in context: http://camel.465427.n5.nabble.com/splitting-xml-failed-when-running-on-tomcat-tp5740407.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: splitting xml failed when running on tomcat

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this FAQ
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

On Mon, Sep 30, 2013 at 5:50 AM, hutao722 <hu...@163.com> wrote:
> i added some logs and observed that the stax works. And in the last
> processor, i can get the split result from content. But the restlet cannot
> set the split result to the entity, the entity returned to client is still
> the entire xml from web service.
>
> Any ideas?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/splitting-xml-failed-when-running-on-tomcat-tp5740407p5740448.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: splitting xml failed when running on tomcat

Posted by hutao722 <hu...@163.com>.
i added some logs and observed that the stax works. And in the last
processor, i can get the split result from content. But the restlet cannot
set the split result to the entity, the entity returned to client is still
the entire xml from web service.

Any ideas?   



--
View this message in context: http://camel.465427.n5.nabble.com/splitting-xml-failed-when-running-on-tomcat-tp5740407p5740448.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: splitting xml failed when running on tomcat

Posted by hutao722 <hu...@163.com>.
Thank you Willem. Solved per your suggestion!



--
View this message in context: http://camel.465427.n5.nabble.com/splitting-xml-failed-when-running-on-tomcat-tp5740407p5740952.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: splitting xml failed when running on tomcat

Posted by "Willem.Jiang" <wi...@gmail.com>.
As you are using splitter you have to aggregator to put the response
together.



--
View this message in context: http://camel.465427.n5.nabble.com/splitting-xml-failed-when-running-on-tomcat-tp5740407p5740482.html
Sent from the Camel - Users mailing list archive at Nabble.com.