Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This component provides a dataformat for xml, which allows serialization and deserialization of request messages and response message using Apache XmlRpc's bindary binary dataformat. You can also invoke the XMLRPC Service through the camel-xmlrpc producer.

Maven users will need to add the following dependency to their pom.xml for this component:

Code Block
xml
xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-xmlrpc</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

...

An example of a typical XML-RPC request would be:

Code Block

<?xml version="1.0"?>
<methodCall>
  <methodName>examples.getStateName</methodName>
  <params>
    <param>
        <value><i4>40</i4></value>
    </param>
  </params>
</methodCall>

An example of a typical XML-RPC response would be:

Code Block

<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
        <value><string>South Dakota</string></value>
    </param>
  </params>
</methodResponse>

A typical XML-RPC fault would be:

Code Block

<?xml version="1.0"?>
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><int>4</int></value>
        </member>
        <member>
          <name>faultString</name>
          <value><string>Too many parameters.</string></value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

URI format

Code Block

xmlrpc://serverUri[?options]

...

To invoke the XmlRpc service, you need to specify the methodName on the message header and put the parameters into the message body like below code, then you can get the result message as you want. If the fault message is return, you should get an exception which cause if XmlRpcException.

Code Block

   String response = template.requestBodyAndHeader(xmlRpcServiceAddress, new Object[]{"me"}, XmlRpcConstants.METHOD_NAME, "hello", String.class);

...