This page last changed on Oct 02, 2006 by alan.cassar.

XFire is a next-generation Soap framework that makes service-oriented development approachable through its easy to use API and support for standards. It is also highly performant since it is built on a low memory StAX based model.

Mule services can be exposed using XFire making them Soap services that use streaming for better memory performance. Right now you can expose Xfire services over http and vm transports, but support for other Mule transports such as JMS, HTTPS, TCP, XMPP and SMTP will also be available soon.

To expose a Mule component as an XFire service all you have to do is set the components receive endpoint to a XFire URL, i.e.

<mule-descriptor name="echoService" implementation="org.mule.components.simple.EchoComponent">
    <inbound-router>
        <endpoint address="xfire:http://localhost:81/services"/>
    </inbound-router>
</mule-descriptor>

 

When Mule starts, the service will be available on http://localhost:81/services/echoService. The Echo component class has a single method called echo that accepts a single parameter string that it will echo back to the client.

To invoke the service you can use the Mule Client i.e.

TestEchoService.java
public static void main(String[] args)
{
    MuleClient client = new MuleClient();
    UMOMessage result = client.send
        ("xfire:http://localhost:81/services/echoService?method=echo", "Hello!", null);
    System.out.println("Message Echoed is: " + result.getPayload());
}

 

When the TestEchoService is run you will see the following output -

Message Echoed is: Hello!

 

Getting the WSDL

To get the WSDL for a XFire service hosted by Mule you add "?wsdl" to the service URL. Using the example service above you would use -

http://localhost:81/services/echoService?wsdl

 

Exposing methods using Interfaces/Abstract Classes...

If you have a service and would like to expose just the methods overriden from a specific interface, then it is easy. The configuration is exactly the same as the way Axis is configured to use Interfaces to expose methods.

<mule-descriptor name="HelloWorld" implementation="com.ricston.components.HelloWorld">
   <inbound-router>
      <endpoint address="xfire:http://localhost:82/services"/>
   </inbound-router>

   <properties>
      <list name="serviceInterfaces">
         <entry value="com.ricston.components.IHelloWorld"/>
      </list>
   </properties>
</mule-descriptor>

Although the property serviceInterfaces is a list, which of course might contain more than one element, only the first interface will be considered.

If you would like to expose methods from two or more interfaces, the work around is very simple. You need to create an abstract class which implements the interfaces you want to expose. In the serviceInterfaces list, then you just need to add this new abstract class.

Messaging Styles

The following describes how to configure diffent messaging styles for XFire services in Mule. To configure the style of service to use you set the style and use properties on the service object i.e.

<mule-descriptor name="echoService" implementation="org.mule.components.simple.EchoComponent">
    <inbound-router>
        <endpoint address="xfire:http://localhost:81/services"/>
    </inbound-router>
    <properties>
        <property name="style" value="document"/>
        <property name="use" value="literal"/>
    </properties>
</mule-descriptor>

 

Doc Lit

TODO

RPC Wrapped

TODO

Message

TODO

RPC Encoded

RPC encoded is not supported by XFire. For this request style you need to use eith the Mule Axis or Glue transport.

Using Other Transports

As well as Http, Mule allows you to expose SOAP services using other transports such as JMS, XMPP, SMTP. The following gives examples of each.

SOAP over VM

Exposing your XFire service over the VM Transport is not very useful in production but is useful for development and testing. To expose the service using VM you specify the xfire and vm protocol and the component name, as shown below -

<mule-descriptor name="echoService" implementation="org.mule.components.simple.EchoComponent">
    <inbound-router>
        <endpoint address="xfire:vm://echoService"/>
    </inbound-router>
</mule-descriptor>

 

SOAP over JMS

TODO

SOAP over HTTPS

TODO

SOAP over XMPP

TODO

SOAP over SMTP

TODO

Document generated by Confluence on Nov 27, 2006 10:27