Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The source code for the HTTP Binding example is located in the ServiceMix installation directory under the examples\http-binding directory in the servicemix.xml file. It is recommended that you refer to the source code while reading this document.

In short, this example invokes a web service to ask for a stock price. In more detail, this example shows how to use an HTTP binding to handle a simple HTTP post. One component acts as the HTTP server, which listens on http://localhost:8912Image Removed, while another component invokes a remote service, implemented as an URLEndpoint. A simple HTTP client is provided so that a simple post can be sent to the server.

...

  1. HttpClient, a Java stand-alone program, connects to http://localhost:8912Image Removed through the URLConnection class. HttpClient sends the file request.xml to this port.
  2. httpReceiver, an HTTP server, being a listener on http://localhost:8912Image Removed receives the message.
  3. httpReceiver sends the message to stockQuote as specified in its destinationService property, via NMR.
  4. stockQuote sends the message into another service, soapEndpoint, for processing.
  5. soapEndpoint sends the response to stockQuote.
  6. stockQuote sends the response to httpReceiver via NMR.
  7. httpReceiver sends the response to http://localhost:8912Image Removed.
  8. HttpClient reads the response.
  9. The response is printed on the console.

Typical output looks like the following two screens.unmigrated-wiki-markup

Output from running {{\[servicemix_install_dir\]\bin\servicemix servicemix.xml}}:

Code Block
  
Loading ServiceMix from file: C:\exist\servicemix\servicemix-2.0.2\examples\http
-binding\servicemix.xml
17:34:34.768 EVENT  Starting Jetty/4.2.20RC0
17:34:34.848 EVENT  Started ServletHttpContext[/]
17:34:34.858 EVENT  Started SocketListener on 127.0.0.1:8912
17:34:34.858 EVENT  Started org.mortbay.jetty.Server@1f06dc3

...

Component or Bean ID

Description

jbi

jbi is the "id" of the JBI container and provides the basic infrastructure services for the following components: httpReceiver and stockQuote. During initialization, several singletons are instantiated: URLEndpoint and JBI. After initialization, the components in the JBI container are activated.

httpReceiver

This component is an HTTP server that listens at

http://localhost/8912Image Removed

. It forwards the message it receives from this URL to stockQuote as specified in its destinationService property in the servicemix.xml file.

stockQuote

This is a SaajBinding component that invokes an endpoint service called soapEndpoint. It is implemented by the SaajBinding class which converts an inbound JBI message into a SAAJ (Soap With Attachments for Java) request-response and sends the response back to httpReceiver. This provides a message centric way of invoking SOAP services inside providers such as Apache Axis. This component invokes a web service to get a stock price.

soapEndpoint

A URLEndpoint object contains a URL, which is used to make connections to the remote party. A stand-alone client can pass a URLEndpoint object to the SOAPConnection method call to send a message.

...