当前位置:首页 > 开发 > 编程语言 > Web Service > 正文

Camel转发WebService请求

发表于: 2015-02-11   作者:ceun   来源:转载   浏览:
摘要: Camel转发WebService请求方法一:  前端为CXF,OSGI-INF/blueprint/blueprint.xml <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprin

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项

Camel转发WebService请求

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号