3

spring-ws で eclipse moxy を使用してオブジェクトをマーシャリングする必要があります。spring-ws を使用して spring-boot プロジェクトを実行しています。すべてのモデル ディレクトリに、moxy jar とすべての jaxb.properties ファイルを含めました。

Spring-WS で jaxb の moxy 実装を使用するにはどうすればよいですか?

注文構成

@Configuration
public class OrderConfiguration {

    @Bean
    public Jaxb2Marshaller marshaller() throws Exception {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setLazyInit(true);
        marshaller.setContextPaths("OMITTED.xcbl.ordermanagement");
        return marshaller;
    }

    @Bean
    public OrderClient orderClient(Jaxb2Marshaller marshaller) throws Exception {
        OrderClient client = new OrderClient();
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);
        return client;
    }

    @Bean
    public ChangeOrderClient changeOrderClient(Jaxb2Marshaller marshaller) throws Exception {
        ChangeOrderClient client = new ChangeOrderClient();
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);
        return client;
    }
}

注文クライアント

public void acceptOrder(OrderResponse orderResponse) {

    try {
        PostDocumentResponse messageAcknowledgment = (PostDocumentResponse) getWebServiceTemplate().marshalSendAndReceive(URI, orderResponse, message -> setSoapHeaderNamespacesAndCredentials((SoapMessage) message));
    } catch (Exception e) {
        logger.error("Soap fault occurred when accepting order.", e);
    }
}

これは、jaxb の Moxy 実装を使用したい場所です。

POM.xml

<dependency>
       <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.moxy</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.2.11</version>
</dependency>
4

0 に答える 0