Apache camel 在ServiceMix中设置OSGI蓝图文件的端点
我知道我可以使用Blueprint语法在独立的xml文件中定义驼峰路线。如果我将其中一个文件移动到ServiceMix的“deploy”文件夹中,它将自动成为一个OSGI包。我的问题是,我可以为这个新包设置一个端点,从外部访问吗 我想这样做:Apache camel 在ServiceMix中设置OSGI蓝图文件的端点,apache-camel,blueprint-osgi,apache-servicemix,Apache Camel,Blueprint Osgi,Apache Servicemix,我知道我可以使用Blueprint语法在独立的xml文件中定义驼峰路线。如果我将其中一个文件移动到ServiceMix的“deploy”文件夹中,它将自动成为一个OSGI包。我的问题是,我可以为这个新包设置一个端点,从外部访问吗 我想这样做: <cxf:cxfEndpoint id="yourId" address="/your/address/to/endpoint" serviceClass="your.java.ServiceClass" wsdlURL="path/
<cxf:cxfEndpoint id="yourId" address="/your/address/to/endpoint"
serviceClass="your.java.ServiceClass"
wsdlURL="path/to/your/wsdl/file.wsdl" />
<from uri="cxf:bean:yourId"/>
blue_route1.xml
<blueprint>
<camelContext>
<route>
<from uri="http:my_servicemix:8181/blue_route1_endpoint" />
<to uri="jetty:http://server1" />
</route>
</camelContext>
</blueprint>
找到了!我不明白这是多么容易。要使ServiceMix侦听端口,我只需使用Camel jetty组件指定端点。 所以,为了回答我的问题,我这样解决: 在ServiceMix中安装驼峰码头组件
______________________
| ____________ |
external-->(blue_route1_endpoint)==|==-->|blue_route1|--|-->(http://server1)
WS | |___________| |
|____________________|
ServiceMix
features:install camel-jetty
在blue_route1.xml文件中,使用Blueprint编写骆驼路线
<?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"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri:="jetty:http:my_servicemix:8181/blue_route1_endpoint">
<to uri="http://localhost:8080/user/services/user?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
</route>
<route>
<from uri="jetty:http://0.0.0.0:6969/sp_role?matchOnUriPrefix=true"/>
<setHeader headerName="Content-Type">
<groovy>"text/xml; charset=utf-8"</groovy>
</setHeader>
<to uri="http://server1"/>
</route>
</camelContext>
</blueprint>
“text/xml;字符集=utf-8”
我用了一个随机端口8181来听。。。但我可以选择每个数字,ServiceMix将自动启动jetty组件,在该端口/端点上侦听和使用。对于您需要的SOAP消息和Web服务的wsdl文件。您可以在camelContext之外配置端点,如下所示:
<cxf:cxfEndpoint id="yourId" address="/your/address/to/endpoint"
serviceClass="your.java.ServiceClass"
wsdlURL="path/to/your/wsdl/file.wsdl" />
<from uri="cxf:bean:yourId"/>
在路线中使用如下标签:
<cxf:cxfEndpoint id="yourId" address="/your/address/to/endpoint"
serviceClass="your.java.ServiceClass"
wsdlURL="path/to/your/wsdl/file.wsdl" />
<from uri="cxf:bean:yourId"/>
您需要将命名空间和schemaLocation添加到蓝图中才能使用cxf命名空间,请使用以下方法:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="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.0/blueprint.xsd
http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
从外部访问是什么意思,使用HTTP是什么意思?然后使用jetty或servlet组件代替http,我希望外部Web服务能够向其发送SOAP消息。是否可能,或者我需要创建一个“假”WS来部署在ServiceMix中,以便使用驼峰路由重定向消息?我更新了问题,试图让问题更清楚