Java 如何使用多个CXF端点在Camel中调用Web服务?
我有两个端点:Java 如何使用多个CXF端点在Camel中调用Web服务?,java,spring,web-services,apache-camel,cxf,Java,Spring,Web Services,Apache Camel,Cxf,我有两个端点: CXF_FIRST_ENDPOINT="cxf:bean:cxfEndpoint?{address=first_address}&serviceClass=com.service.class.first" CXF_SECOND_ENDPOINT="cxf:bean:cxfEndpoint?{address=second_address}&serviceClass=com.service.class.second" 在定义端点之后,如何实现两个单独的web服务调用
CXF_FIRST_ENDPOINT="cxf:bean:cxfEndpoint?{address=first_address}&serviceClass=com.service.class.first"
CXF_SECOND_ENDPOINT="cxf:bean:cxfEndpoint?{address=second_address}&serviceClass=com.service.class.second"
在定义端点之后,如何实现两个单独的web服务调用。如果我同时使用这两个端点,并使用路由使用端点,那么其中一个端点将覆盖另一个端点,并且我只能使用一个端点。如果我对另一个端点进行注释,那么它将成功运行。然而,我需要两者都使用。我将messageContentList用于web服务响应:
MessageContentsList result = (MessageContentsList) exchange.getIn().getBody();
谢谢,如果您需要更多信息,请告诉我
以下是路线定义:
from("direct:paymentInfo").routeId("PaymentInfo")
.bean(billingServiceProcessor, "processBillingPaymentRequest")
.to(CXF_BILLINGSERVICE_ENDPOINT)
.bean(billingServiceProcessor, "processBillingPaymentResponse")
.end();
from("direct:Holidays").routeId("HolidayRetrieval")
.bean(entityProcessor, "processHolidaysRequest")
.to(CXF_ENTITYSERVICE_ENDPOINT)
.bean(entityProcessor, "processHolidaysResponse")
.end();
我解决了这个问题。我发现两个端点使用的是camel-config.xml中定义的同一个beanid(cxfEndpoint) 我在camel-config.xml中定义了另一个id cxfEndpoint1,并将其用于我的端点,从而解决了问题。这两个web服务调用都工作正常,没有任何麻烦
<bean id="cxfEndpoint" class="org.apache.camel.component.cxf.CxfEndpoint" />
<bean id="cxfEndpoint1" class="org.apache.camel.component.cxf.CxfEndpoint"/>
谢谢,为什么不创建两条路由,每条路由监听来自其端点的传入请求?当前逻辑被重构为一个新的路由
from(“direct:processRequest”)
,每个端点路由通过将请求转发到(“direct:processRequest”)
到processingRequest路由。我创建了两个单独的路由,并为这两个路由创建了单独的请求响应方法。但是端点仍然相互覆盖。从(“direct:paymentInfo”).routeId(“paymentInfo”).bean(billingServiceProcessor,“processBillingPaymentRequest”)。到(CXF_BILLINGSERVICE_ENDPOINT).bean(billingServiceProcessor,“processBillingPaymentResponse”).end();from(“direct:Holidays”).routeId(“HolidayRetrieval”).bean(entityProcessor,“processHolidaysRequest”).to(CXF_ENTITYSERVICE_ENDPOINT).bean(entityProcessor,“processHolidaysResponse”).end();
CXF_FIRST_ENDPOINT="cxf:bean:cxfEndpoint?{address=first_address}&serviceClass=com.service.class.first"
CXF_SECOND_ENDPOINT="cxf:bean:cxfEndpoint1?{address=second_address}&serviceClass=com.service.class.second"