加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

osgi2——camel网关调用其它系统webservice

发布时间:2020-12-16 22:21:33 所属栏目:安全 来源:网络整理
导读:上一节介绍了怎么用camel和cxf去起一个webservice,这节介绍怎么用camel去调用其它系统的webservice。 请看blueprint.xml的配置 ?xml version="1.0" encoding="UTF-8"?blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.

上一节介绍了怎么用camel和cxf去起一个webservice,这节介绍怎么用camel去调用其它系统的webservice。

请看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:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
           xmlns:camel-cxf="http://camel.apache.org/schema/blueprint/cxf" 
           xmlns:cxfcore="http://cxf.apache.org/blueprint/core" 
           xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd">

	<camelContext  id="myCamelContext" xmlns="http://camel.apache.org/schema/blueprint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
        <route>
            <from uri="<span style="font-family: Arial,Helvetica,sans-serif;">vm:_WGTest</span>"/>
            <to uri="cxf:http://192.168.1.100:8081/test?wsdlURL=http://192.168.1.100:8081/test?wsdl&dataFormat=RAW"/>           
        </route>
    </camelContext>
	
 
    <bean id="gwrequest" class="com.cn.yyc.GWRequest">
        <property name="camelcontext" ref="myCamelContext"/>
    </bean>
</blueprint>	

下面是com.cn.yyc.GWRequest

public class GWRequest{
    private static final Logger log = LoggerFactory.getLogger(GWRequest.class);
    private CamelContext camelcontext;
	public void setCamelcontext(CamelContext camelcontext) {
        this.camelcontext = camelcontext;
    }

    @EndpointInject(uri = "vm:_WGTest")
    private ProducerTemplate producer;


    private String invoke(String xml){
        Exchange exch = camelcontext.getEndpoint("vm:_WGTest").createExchange();
        exch.setPattern(ExchangePattern.OutIn);
        exch.getIn().setHeader("SOAPAction","""");
        exch.getIn().setBody(xml);//报文内容
        producer.send("vm:_WGTest",exch);
        return exch.getOut().getBody(String.class);
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读