Warning

This component has been deprecated in favor to servicemix-http component.

We support both a client side HTTP (capable of invoking requests on remote HTTP servers) and a server side HTTP binding (for exposing JBI components over HTTP). Note that both these 2 components are pure HTTP bindings; they assume that a REST or SOAP service creates the inbound request first. So they just deal with the HTTP transport and do not perform any protocol encoding such as SOAP 1.1 or SOAP 1.2; they pass along the XML they are given.

Client side HTTP invocation

This JBI component uses Commons HttpClient to perform client side HTTP invocations. Here is a typical example of a JBI component which performs a HTTP invocation when it is invoked.

{snippet:id=send|lang=xml|url=servicemix/smx3/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/http/example.xml}

Server side HTTP binding

This JBI component will expose another JBI component over HTTP on some port and HTTP configuration. We use an embedded Jetty component for this, though we also have a BindingServlet which can be configured from inside any web.xml in a Servlet WAR.

Here's an example of configuring the default HTTP connector.

{snippet:id=binding|lang=xml|url=servicemix/smx3/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/http/example.xml}

Using HTTP binding in a WAR

You may wish to configure ServiceMix's HTTP binding inside a WAR. To do this you need to register one or more instances of the SpringBindingServlet in your web.xml then map the servlet to the URI you wish.

Here's an example

{snippet:id=httpBinding|lang=xml|url=servicemix/smx3/tags/servicemix-3.0-M2-incubating/servicemix-web/src/webapp/WEB-INF/web.xml}

Notice that the web.xml then refers to the endpoint name httpBinding in the ServiceMix configuration file. e.g. this component

{snippet:id=http|lang=xml|url=servicemix/smx3/tags/servicemix-3.0-M2-incubating/servicemix-web/src/webapp/WEB-INF/applicationContext.xml}

Example of using the HTTP binding in a WAR

The ServiceMix WAR comes with an example of using a HTTP GET or POST to invoke a JBI operation. To run the example get the latest checkout then perform the following

cd tooling/servicemix-web maven run

Then point your browser to http://localhost:8080/examples/

You should see the simple demo which performs a HTTP GET/POST into the JBI container and shows the result in your browser. This example renders better in FireFox which handles XML response types nicer than Safari.

An alternative is to use your existing Servlet engine and type this instead

maven war

Then deploy the war into your servlet engine. You'll typically need to use a different URL then such as http://localhost:8080/servicemix-web/examples/

More detail

See the WAR Deployment

  • No labels