2016-08-16 7 views
1

実際に私は春には非常に新しく、いくつかの要件のために、私は春の統合に取り組んでおり、データをXMLに変換するためのJAXBクラスをほとんど作成していません。私が作ったのと同じJAXBクラスを使って新しいXMLをアンマーシャリングする方法を知りたいですか?JAXBを使用してXMLをアンマーシャリングする

答えて

1

私は(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; 
    } 
関連する問題