3

我需要使用 eclipse moxy 和 spring-ws 来编组一个对象。我正在使用 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