views:

118

answers:

2

I need to create a mule service that will POST data to a web service that expects name/value pairs (not xml), then process the XML response from that service. I cannot find a good example on how to prep the payload for an http POST.

Can someone provide some insight or examples?

What I have so far is (I don't know if 'PathToTransformerClass' is needed):

    <service name="myService">
        <inbound>
            <vm:inbound-endpoint path="myService.request" synchronous="true">
                <custom-transformer class="PathToTransformerClass" />
            </vm:inbound-endpoint>
        </inbound>
        <outbound>
            <pass-through-router>
                <http:outbound-endpoint address="URIofWebServiceToPostTo" method="POST" synchronous="true">
                    <response-transformers>
                        <custom-transformer class="PathToClassToProcessTheResponse" />
                    </response-transformers>
                </http:outbound-endpoint>
            </pass-through-router>
        </outbound>
    </service>
A: 

Are you asking about how to take XML and create key value pairs to send out via HTTP? For that you can use an XLST transformer where in the XSL you set the method output to be text.

Roko
A: 

The following might be helpful: http://comments.gmane.org/gmane.comp.java.mule.user/29342

I can't find any examples either, but it looks like the built-in HTTP transformers are

http-response-to-object-transformer A transformer that converts an HTTP response to a Mule Message. The payload may be a String, stream, or byte array.

http-response-to-string-transformer Converts an HTTP response payload into a string. The headers of the response will be preserved on the message.

object-to-http-request-transformer This transformer will create a valid HTTP request using the current message and any HTTP headers set on the current message.

message-to-http-response-transformer This transformer will create a valid HTTP response using the current message and any HTTP headers set on the current message.

object-to-http-request-transformer might be your best bet; perhaps you can create a map of key-value pairs and then convert that into URL encoded form? Not sure but hopefully this gives you some things to Google.

I82Much