Camel转发WebService请求

Camel转发WebService请求方法一:

?前端为CXF,OSGI-INF/blueprint/blueprint.xml

<?xml version="1.0" encoding="UTF-8"?>

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
	xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"
	xsi:schemaLocation="
        http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.1/blueprint.xsd">

	<camelcxf:cxfEndpoint id="greetingService"
		address="http://localhost:9080/greeting" endpointName="s:GreetingSoap"
		serviceName="s:GreetingService" wsdlURL="wsdl/greeting.wsdl"
		xmlns:s="http://demo.ceunfish.org/greeting" />


	<camelContext xmlns="http://camel.apache.org/schema/blueprint">
		<endpoint id="realWebService"
			uri="http://192.168.4.100:8080/greeting?throwExceptionOnFailure=false&amp;bridgeEndpoint=true" />
		<route id="GreetingServiceRoute">
			<from uri="cxf:bean:greetingService?dataFormat=MESSAGE" />
			<convertBodyTo type="String" />
			<to uri="log:input?showHeaders=true" />
			<to ref="realWebService" />
			<convertBodyTo type="String" />
			<to uri="log:output?showHeaders=true" />
		</route>
	</camelContext>
</blueprint>

?方法二:

前端为jetty,OSGI-INF/blueprint/blueprint.xml

<?xml version="1.0" encoding="UTF-8"?>

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
	xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"
	xsi:schemaLocation="
        http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.1/blueprint.xsd">

	<camelContext xmlns="http://camel.apache.org/schema/blueprint">
		<endpoint id="realWebService"
			uri="http://192.168.4.100:8080/greeting?throwExceptionOnFailure=false&amp;bridgeEndpoint=true" />
		<route id="GreetingServiceRoute">
			<from uri="jetty:http://localhost:8989/greeting" />
			<convertBodyTo type="String" />
			<to uri="log:input?showHeaders=true" />
			<to ref="realWebService" />
			<convertBodyTo type="String" />
			<to uri="log:output?showHeaders=true" />
		</route>
	</camelContext>
</blueprint>

?

区别:利用CXF作前端,?wsdl展示的WSDL为指定的wsdl,但是当SOAPAction为空时请求头会缺少SOAPAction项,这样对于AXIS开发的webservice会报no soapAction header错误;

利用jetty作前端,?wsdl展示的为目标服务的wsdl,SOAPAction为空时请求头也不会丢失SOAPAction项

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。