Before writing the content, mule just 3.0.1, many official documents have not been updated (especially the sample code) to maintain the status in V2. After more than a year, the Mule Community Edition was developed to version 3.2, and the Mule Studio Visual development tool (currently beta status, supported by Mule 3.1.2) was launched.
The sample code that you previously verified was run again (some changes) on version 3.1.2, and here's a record.
one. Service invocation
1. Mule implements and provides Web Service
A Web service is developed and published on Mule for client invocation. Sample Configuration
<flow name= "Local-ws" >
<core:inbound-endpoint address= "Http://localhost:65082/services/Echo1"
Exchange-pattern= "Request-response" doc:name= "Generic" doc:description= "Generic endpoint specified by address URI"/ >
<cxf:jaxws-service serviceclass= "Demo.mule.component.Echo" doc:name= "SOAP"
Doc:description= "Make a Web service available via CXF"/>
<component doc:name= "component" doc:description= "Invoke a Java component" >
<singleton-object class= "Demo.mule.component.Echo"/>
</component> </Flow > test method Enter "Http://localhost:65082/services/Echo1/echo/text/hello" in the browser address bar, Return result information will be displayed in the browser after carriage return. The "echo" in the address is the method of the service, "text" is the parameter of the method, and "Hello" is the value of the parameter.
2. Web Service Proxy
The Web Service Proxy is used to forward the client's WS request directly to the corresponding remote WS-Server processing and returns the processing result. Mule itself does not do any processing.
2.1 Configuration Mode 1 Sample Configuration
<flow name= "Local2remote-ws" >
encoding= "UTF-8" disabletransporttransformer= "false" exchange-pattern= "Request-response" doc:name= "HTTP"
Doc:description= ""/>
Address= "Http://localhost:5050#[header:inbound:http.request]" responsetimeout= "10000" encoding= "UTF-8"
Disabletransporttransformer= "false" followredirects= "false" exchange-pattern= "Request-response"
Doc:name= "HTTP" doc:description= ""/> </Flow > Description Note the expression in the address parameter in Outbound-endpoint. test the method in the browser by "http://localhost:65000/webservice/EchoService?wsdl" (Copy the content, save it as *.WSDL), and then use the SOAPUI test.
2.2 Configuration Mode 2 Sample Configuration
<pattern:web-service-proxy name= "Ws-proxy" inboundaddress= "Http://localhost:65082/services/Echo2"
outboundaddress= "Http://localhost:65082/services/Echo1?method=echo" >
</pattern:web-service-proxy> Description Mule provides a ready-made pattern for this common scenario to simplify configuration. The test method obtains the WSDL file through "http://localhost:65082/services/Echo2?wsdl" and then uses the SOAPUI test.
3. Web Service to Web service
The Web service to Web service is used to provide a Web service in mule for client calls, mule receives the request, calls the remote Web service for processing, and returns the result. Sample Configuration
<flow name= "Local-ws2remote-ws" >
<core:inbound-endpoint address= "Http://localhost:65082/services/Echo8"
Disabletransporttransformer= "false" exchange-pattern= "Request-response" doc:name= "Generic"
doc:description= "Generic endpoint specified by address URI"/>
<cxf:jaxws-service serviceclass= "Demo.mule.component.Echo" doc:name= "SOAP"
Doc:description= "Make a Web service available via CXF"/>
<core:outbound-endpoint
address= "Wsdl-cxf:http://server1:5050/mule-business/webservice/echoservice?wsdl&method=echo"/> </ Flow > Note Notice how the address parameter is configured in Outbound-endpoint, using the WSDL-CXF prefix to indicate that this Web service is provided by CXF. test method Enter "Http://localhost:65082/services/Echo8/echo/text/hello" in the browser to test.
4. Socket to socket
The socket to socket is used to forward the client's socket request to the remote socket server processing and returns the processing result. Sample Configuration
<flow name= "Tcp2tcp" >
<tcp:inbound-endpoint host= "localhost" port= "7100" responsetimeout= "10000"
encoding= "UTF-8" disabletransporttransformer= "false" exchange-pattern= "Request-response" doc:name= "TCP"
Doc:description= "The TCP transport enables events to being sent and received over TCP sockets."/>
<tcp:outbound-endpoint host= "localhost" port= "7000" responsetimeout= "10000"
encoding= "UTF-8" disabletransporttransformer= "false" exchange-pattern= "Request-response" doc:name= "TCP"
Doc:description= "The TCP transport enables events to being sent and received over TCP sockets."/> </flow > Instructions /c0> main configuration host, port parameter, indicating the service address. The test method tests the class through the Simpleserver and SimpleClient, starts the Simpleserver first, then initiates the simpleclient, sends the request, and receives the processing result.
5. JMS Topic
The client sends a Web service request, Mule sends the request message to the remote JMS topic. Sample Configuration
<flow name= "Local-ws2jms-topic" >
<core:inbound-endpoint address= "Http://localhost:65082/services/Echo3"
Responsetimeout= "10000" encoding= "UTF-8" disabletransporttransformer= "false" mimetype= "Text/plain"
exchange-pattern= "One-way" doc:name= "Generic" doc:description= "Generic endpoint specified by address URI"/>
<cxf:jaxws-service serviceclass= "Demo.mule.component.Echo" doc:name= "SOAP"
Doc:description= "Make a Web service available via CXF"/>
<jms:outbound-endpoint topic= "Topic1" responsetimeout= "10000" encoding= "UTF-8"
Disabletransporttransformer= "false" disabletemporaryreplytodestinations= "false" exchange-pattern= "one-way"
connector-ref= "Activemqconnector" doc:name= "JMS" doc:description= "Send or receive messages from a JMS queue"/>
</flow>
<flow name= "Jms-topic2echo" >
<jms:inbound-endpoint topic= "Topic1" responsetimeout= "10000" encoding= "UTF-8"
Disabletransporttransformer= "false" disabletemporaryreplytodestinations= "false" exchange-pattern= "one-way"
connector-ref= "Activemqconnector" doc:name= "JMS" doc:description= "Send or receive messages from a JMS queue"/>
<echo-component doc:name= "echo" doc:description= "echoes message payload."/> </Flow > description JMS endpoi NT is one-way and does not require a return value. Specifies the topic name of the JMS server through the topic property, Connector-ref indicates the JMS connection used. test method Enter "Http://localhost:65082/services/Echo3/echo/text/hello" in the browser address bar to send the request, The Mule console outputs subscribers ' processing results (a JMS subscriber is configured through mule in the above example). You can also see the addition of a published message to topic through the ACTIVEMQ console.
two. Message content-based routing
Mule provides a routing mechanism based on message content that sends messages to different service sides for processing based on the information specified in the message.
1. Socket to socket Routing sample configuration
<flow name= "Tcp2tcp-router" >
<tcp:inbound-endpoint host= "localhost" port= "7101" responsetimeout= "10000"
encoding= "UTF-8" disabletransporttransformer= "false" exchange-pattern= "Request-response" doc:name= "TCP"
Doc:description= "The TCP transport enables events to being sent and received over TCP sockets."/>
<choice>
<when evaluator= "Jxpath" expression= "(req/area) = ' BJ '" >
<tcp:outbound-endpoint host= "Server1" port= "7101"
Responsetimeout= "10000" encoding= "UTF-8" disabletransporttransformer= "false" exchange-pattern= "Request-response"
Doc:name= "TCP" doc:description= "the TCP transport enables events to being sent and received over TCP sockets."/>
</when>
<when evaluator= "Jxpath" expression= "(req/area) = ' sh '" >
<tcp:outbound-endpoint host= "Server1" port= "7102"
Responsetimeout= "10000" encoding= "UTF-8" disabletransporttransformer= "false" exchange-pattern= "Request-response"
Doc:name= "TCP" doc:description= "the TCP transport enables events to being sent and received over TCP sockets."/>
</when>
</choice> </Flow > explains that routes use <choice>, <when> elements, which represent routing branches. The When element uses evaluator to indicate how the expression is parsed, using expression to describe the condition in which the message content is judged. test method with socket to socket test, message content is <req><area>bj</area></req>, <req><area >sh</area></req> View the output sent to a different server.
2. Web Service to JMS Topic routing sample configuration
<flow name= "Local-ws2jms-topic-router" >
<core:inbound-endpoint address= "Http://localhost:65082/services/Echo7"
Disabletransporttransformer= "false" exchange-pattern= "Request-response" doc:name= "Generic"
doc:description= "Generic endpoint specified by address URI"