Servicemix 7 installation and use and camel-cxf proxy webservice

The foregoing: I used servicemix3 to proxy webservice through jbi before. Since the smx version is upgraded quickly, smx7 has deprecated jbi and switched to the camel conversion protocol.

Servicemix 3 installation and cxf-bc component proxy webservice servicehttp://newjava-sina-cn.iteye.com/blog/2357092This
article

is mainly to learn the learning process of proxying ws through camel.


1. Install and use servicemix7

2.camel-cxf proxy webservice

3. Common commands





1. Install and use servicemix7 to
download servicemix:
http://servicemix.apache.org/downloads/servicemix-7.0.0.M2.html

Unzip it to a certain path Below, such as: D:\service\apache-servicemix-7.0.0.M2

configure the system variable SERVICEMIX_HOME=D:\service\apache-servicemix-7.0.0.M2

enter the bin directory, run servicemix.bat to start servicemix



Through the console shell, you can view features or control servicemix, such as:
bundle:list show installed components
bundle:list | grep camel find specific components
log:display View logs
log:display | grep DEBUG Find debug logs
log:set INFO Set log level
feature:list View features (both installed and not installed)
feature:list | grep camel View features of interest

feature:install webconsole install After the web console

is successfully installed, visit http://localhost:8181/system/console smx/smx. Through the web page, you can start or stop components, install original features, etc.

Since installing some components may require downloading dependent jar packages from the maven library, the network speed is slow. You can change the maven library to a domestic one (etc/org.ops4j.pax.url.mvn.cfg for the org.ops4j.pax.url.mvn.repositories)






2. Camel-cxf proxy webservice
to create a new normal maven in eclipse The project project (according to the maven-archetype-quickstart prototype)

creates a new META-INF/spring/camel-config.xml (a structure that smx7 can recognize) under the src/main/resources source file.

Configure camel-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
 
  <!-- this is the CXF web service we use as the front end -->
  <cxf:cxfEndpoint id="reportIncident"
                   address="http://0.0.0.0:8186/camel_0319_cxf/camel/CXF_HELLO_ObjectSpringService/IHello"
                   serviceName="s:HelloWorldService"
                   endpointName="s:HelloWorld"
                   wsdlURL="http://localhost:8081/HelloWorld/services/HelloWorld?wsdl"
                   xmlns:s="http://ws.bill.com"/>
 
  <!-- this is the Camel route which proxies the real web service and forwards SOAP requests to it -->
  <camelContext xmlns="http://camel.apache.org/schema/spring">
 
    <!-- <endpoint id="callRealWebService" uri="http://localhost:${real.port}/real-webservice?throwExceptionOnFailure=false"/> --><!-- & -->
    <endpoint id="callRealWebService" uri="http://localhost:8081/HelloWorld/services/HelloWorld?bridgeEndpoint=true"/>
 
    <route>
      <!-- CXF consumer using MESSAGE format -->
      <from uri="cxf:bean:reportIncident?dataFormat=MESSAGE"/> <!-- ?dataFormat=MESSAGE -->
      <setHeader headerName="SOAPAction" >
          <constant>FooSync</constant>
      </setHeader>
      <convertBodyTo type="String" />
      <!-- log input received -->
      <to uri="log:input?showHeaders=true"/>
      <!-- enrich the input by ensure the incidentId parameter is set -->
      <!-- <to uri="bean:enrichBean"/> -->
      <!-- Need to remove the http headers which could confuse the http endpoint -->
      <!-- <removeHeaders pattern="CamelHttp*"/> -->
      <!-- send proxied request to real web service -->
      <to ref="callRealWebService"/>
      <convertBodyTo type="String" />
      <!-- log answer from real web service -->
      <to uri="log:output?showHeaders=true"/>
    </route>
 
  </camelContext>
 
</beans>


Notes:
a. This configuration is based on the official camel instance (http://camel.apache.org/cxf-proxy-example.html) (see attachment camel-example-cxf-proxy-2.11.1-sources .jar.7z), set the endpoint.uri of callRealWebService according to your own server address

b. When configuring the cxf:cxfendpoint endpoint, xmlns:s should be the command space of your own webservice, targetNamespace="http://ws. bill.com". serviceName is the service name of the service, endpointName is the port name of the service

c. For the ws of the axis, if there is no soapAction in the request header, an error similar to the no soapAction header will be reported. The ws of cxf will not have this problem, you can remove this configuration

d .Readers can query relevant information and debug the relevant components in the route. After the


configuration is complete, right-click the project and run as - maven install to generate components, generate a jar package in the target folder, put it in the deploy folder of smx7, and automatically deploy the

log . data/log/servicemix.log

Visit http://localhost:8186/camel_0319_cxf/camel/CXF_HELLO_ObjectSpringService/IHello?wsdl
or test



the modified , which can be downloaded from the attachment



3. Common command
log:display displays the log

feature:install camel-http





reference website:
http://camel.apache.org/cxf-proxy-example.html

https://access.redhat.com/documentation/en-US/Fuse_ESB_Enterprise/7.0/html-single/ Web_Services_and_Routing_with_Camel_CXF/index.html#Proxying-HTTP

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326654112&siteId=291194637