2
votes

I have a requirement to pass an object to an HTTP connector (Not sure if I can use any other connector). The next step is convert an object to a CXML and make an outbound end point call to another API, get the response and convert it another java object. I am very new to Mule and need some inputs on this. Any pointers would be very helpful.

Can someone give me some good points where we have good links for mule implementation examples (apart from Mule in Action)

EDIT: code from OP's comment below

<flow name="object_serialization.mflowFlow1" doc:name="object_serialization.mflowFlow1">
  <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
  <component class="SerializeObject" doc:name="Java"/>
  <serializable-to-byte-array-transformer doc:name="Serializable to Byte Array"/>
  <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" doc:name="HTTP"/>
</flow>
1
How do you plan to serialize the Java object you'll be passing to the inbound HTTP endpoint? - David Dossot
I am planning to write it to a file and pass the path. Is there any other way of efficiently doing it? Please advise. - Lakshmisri
Hi David, What are the connectors I can use for for this requirement. Can you help/ - Lakshmisri
How will you write the Java object to the file? Pure Java serialization? And you will HTTP POST the file location or the content of the file to Mule? - David Dossot
Yes, I was thinking of pure java serialization. Can I use Mule for the who end to end implementation. I am very new to Mule but its very interesting and I would want to use this. - Lakshmisri

1 Answers

1
votes

You can achieve your goal with Mule:

  • On the client side:
    • Serialize the Java object with serializable-to-byte-array-transformer
    • HTTP POST it with an http:outbound-endpoint
  • On the server side:
    • Receive the HTTP POST with an http:inbound-endpoint
    • Deserialize the Java object with byte-array-to-serializable-transformer

This assumes the Java object implements java.io.Serializable, which should be the case since you stated you want to use Java serialization. This also assumes that the necessary Java classes are available on the classpath of both client and server Mules.