0

基于 javax.xml.bind.JAXBElement 的有效负载类型路由的最佳路由解决方案是什么?这是我目前的配置。

<oxm:jaxb2-marshaller id="wsMarshaller" contextPath="com.test.conn.ws.domain"/>

<int:channel id="jaxbInputChannel" />

<int-ws:inbound-gateway id="wsInboundMarsellingGateway"
    request-channel="jaxbInputChannel" marshaller="wsMarshaller" unmarshaller="wsMarshaller" />

<int:service-activator input-channel="jaxbInputChannel">
<bean class="com.test.conn.application.AImpl" />

<int:service-activator input-channel="jaxbInputChannel">
<bean class="com.test.conn.application.BImpl" />

在 AImpl 和 BImpl 中接收的有效负载类型是 javax.xml.bind.JAXBElement 和 javax.xml.bind.JAXBElement。但是当我使用soapUI 调用B 请求时,它调用了AImpl。有更多的服务激活器(针对不同的有效负载类型),在调用哪个服务激活器时会有更多的混乱。

所以决定通过添加PayloadTypeRouter来解决这个问题,但是问题是如何为javax.xml.bind.JAXBElement、javax.xml.bind.JAXBElement等类型定义它。

我希望有一个使用 SpEL(或另一种直接方式)的简单解决方案,而不是在前面添加一个转换器来获取请求 getValue.. 任何建议都会有很大帮助。

谢谢。


正如前面文章中提到的,我继续使用 PayloadTypeRouter,transformer 实现。在那里我遇到了另一个路障。

<int:transformer input-channel="jaxbInputChannel" output-channel="jaxbRoutingChannel"  >
    <bean class="com.test.conn.transformer.ConnTransformer" />
</int:transformer>

<int:payload-type-router input-channel="jaxbRoutingChannel"  >
    <int:mapping type="com.test.conn.ws.domain.A" channel="aInputChannel" />
    <int:mapping type="com.test.conn.ws.domain.B" channel="bInputChannel" />
</int:payload-type-router>

这是我收到的错误消息。

原因:org.springframework.expression.spel.SpelEvaluationException:EL1004E:(pos 8):方法调用:在 com.sun.proxy.$Proxy40 上找不到方法 test(com.test.conn.ws.domain.A)类型

我很困惑。为什么 spring 会查看 com.test.conn.ws.domain.A 实例中的服务激活器方法?

4

0 回答 0