使用JAXB解组XML

乌塔卡什

实际上,我在春季刚接触新手,目前由于某些要求,我正在与春季集成一起工作,我制作了很少的JAXB类来将数据转换为XML并必须通过Web服务发送,但作为回应,我将XML找回来有了一些新元素,我想知道如何用我制作的相同JAXB类解组新XML?

crm86

我使用以下组件来做到这一点(java配置):

    @Bean
    public Jaxb2Marshaller jaxb2Marshaller() throws Exception {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); 
        /* Packages with root elements (@XmlRootElement). Your JAXB classes  */     
        marshaller.setContextPaths("...");
        return marshaller;
    }   

    @Bean
    @ServiceActivator(inputChannel = "toWebServiceChannel")
    public MessageHandler wsGateway() throws Exception {                    
        ConfigWebServiceURLProvider provider = new ConfigWebServiceURLProvider(isHttps, host, port, endpoint);
        /* marshaller and unmarshaller could be the same */  
        MarshallingWebServiceOutboundGateway gw = new MarshallingWebServiceOutboundGateway(url, jaxb2Marshaller(), jaxb2Marshaller());
        gw.setOutputChannelName( "fromWebServiceChannel" );
        return gw;
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章