Transform rest request to soap body

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Transform rest request to soap body

Adrian Brenes-2
Hello,

I'm making my first steps on mule 2.2, trying to convert an http request to a soap body so i can send a request to a webservice, ie:

http://localhost:8081/test/id/12345  -> xslt transformation to soap message -> call to webService

I'm having trouve with the xslt transformation; error is org.xml.sax.SAXParseException: Content is not allowed in prolog. (net.sf.saxon.trans.DynamicError).

I tried a lot of transformers, even a few copy/pasted from exemples just to see if the payload is modified, but always this error, so no transformation, the payload stays "/test/id/12345".

The only transformation i managed to use without error was the append-string one :o

So can i send to an xslt transformer a simple payload like "/test/id/12345" , or do i have to use a common transformer before calling the rest to soap transformer?

I'm kinda lost on this one, help would be greatly apprecied.

Thanks a lot.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

ddossot
You do realize that "/test/id/12345" is not XML? The XSLT transformer works only with XML inputs.

D.


On Wed, Dec 29, 2010 at 7:52 AM, benny boy <[hidden email]> wrote:
Hello,

I'm making my first steps on mule 2.2, trying to convert an http request to a soap body so i can send a request to a webservice, ie:

http://localhost:8081/test/id/12345  -> xslt transformation to soap message -> call to webService

I'm having trouve with the xslt transformation; error is org.xml.sax.SAXParseException: Content is not allowed in prolog. (net.sf.saxon.trans.DynamicError).

I tried a lot of transformers, even a few copy/pasted from exemples just to see if the payload is modified, but always this error, so no transformation, the payload stays "/test/id/12345".

The only transformation i managed to use without error was the append-string one :o

So can i send to an xslt transformer a simple payload like "/test/id/12345" , or do i have to use a common transformer before calling the rest to soap transformer?

I'm kinda lost on this one, help would be greatly apprecied.

Thanks a lot.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

Adrian Brenes-2
Well looking at mule docs it seemed to me that xslt transformers could take whatever input , as long as you give it the right params you're using in its transformation description.

Maybe i'm going in the wrong direction , what would be the good practice to go from a rest request to a soap body?

Thanks.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

ddossot

Just to be sure I understand: you want to build SOAP requests out of HTTP GET requests by extracting arguments from the inbound query path (as opposed to receiving HTTP POSTed XML entities).

On Dec 29, 2010 8:25 AM, "benny boy" <[hidden email]> wrote:

Well looking at mule docs it seemed to me that xslt transformers could take whatever input , as long as you give it the right params you're using in its transformation description.

Maybe i'm going in the wrong direction , what would be the good practice to go from a rest request to a soap body?

Thanks.


---------------------------------------------------------------------
To unsubscribe from this list...

Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

Adrian Brenes-2
yes, that's what i want to do.
argument extraction seems to work fine with restlet:uri-template-filter , as i can see arguments' keys/values  when using a logger transformer

(dunno why but i see this post in another thread than the one i created)

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

ddossot
So I'd say you have three options:
  • build an XML out of the arguments' keys/values with a custom transformer and use the XSLT transformer to build the SOAP envelope,
  • same but use the SAAJ transport instead of XSLT,
  • do everything with a single Groovy transformer using the markup builder to generate the SOAP envelope.
I'd personally go for the last option as it is trivial to do and imply a single transformer, but it's a matter of taste :)

HTH
D.


On Wed, Dec 29, 2010 at 9:50 AM, benny boy <[hidden email]> wrote:
yes, that's what i want to do.
argument extraction seems to work fine with restlet:uri-template-filter , as i can see arguments' keys/values  when using a logger transformer

(dunno why but i see this post in another thread than the one i created)

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

Adrian Brenes-2
Thanks a lot , i'll give the groovy transformer a try.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

ddossot
To get you started (assuming SOAP 1.1):

def writer = new StringWriter()
def soap = new groovy.xml.MarkupBuilder(writer)

soap.'soapenv:Envelope'('xmlns:soapenv': 'http://schemas.xmlsoap.org/soap/envelope/') {
'soapenv:Body' {
  'yourNs:yourElement'('xmlns:yourNs': 'http://your.ns') {
...
      }
   }
  }
}

writer.toString()

On Wed, Dec 29, 2010 at 11:47 AM, benny boy <[hidden email]> wrote:
Thanks a lot , i'll give the groovy transformer a try.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

Adrian Brenes-2
In reply to this post by Adrian Brenes-2
Thanks for your help, my transformation works fine.
The groovy transformation works fine and is easy to write, i also managed to use my xslt transformer, by using the object-to-xml-transformer before the custom xslt one.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

ddossot
Congrats, you've learned quite a few tricks :)


On Thu, Dec 30, 2010 at 5:55 AM, benny boy <[hidden email]> wrote:
Thanks for your help, my transformation works fine.
The groovy transformation works fine and is easy to write, i also managed to use my xslt transformer, by using the object-to-xml-transformer before the custom xslt one.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

xcepttj
In reply to this post by Adrian Brenes-2
I'm getting following error after choosing objec-to-xml transformer.
********************************************************************************
Message               : Could not call org.mule.DefaultMuleMessage.writeObject() : Could not call org.mule.MessagePropertiesContext.writeObject() : Could not call org.mule.util.CaseInsensitiveHashMap.writeObject() : Could not call org.mule.DefaultMuleEvent.writeObject() : Unable to serialize the flow variable jersey_response, which is of type com.sun.jersey.spi.container.ContainerResponse@4196c169
---- Debugging information ----
message             : Could not call org.mule.DefaultMuleEvent.writeObject()
cause-exception     : java.io.IOException
cause-message       : Unable to serialize the flow variable jersey_response, which is of type com.sun.jersey.spi.container.ContainerResponse@4196c169
Reply | Threaded
Open this post in threaded view
|

Re: Transform rest request to soap body

xcepttj
In reply to this post by Adrian Brenes-2
I 'm following the step mentioned. I'm currently using mule 3.4 no restlet uri filter.
This is my flow looks like
  <context:property-placeholder location="config.properties"/> 
    <flow name="hhmi-PS-IntegrationFlow" doc:name="hhmi-PS-IntegrationFlow">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081"  doc:name="HttpPSMangerRequest" />
        <jersey:resources doc:name="REST">
            <component class="org.hhmi.rest.GetManagerInfo"/>
        </jersey:resources>
         <custom-transformer class="org.hhmi.transformer.JerseyTransformer" doc:name="Java"/>
            <message-properties-transformer doc:name="Message Properties">
               
                <add-message-property key="outboundVendorId" value="#[header:INBOUND:vendorid]"/>
            </message-properties-transformer>
        <logger message="#[payload]" level="DEBUG" doc:name="Logger"/>
       
        <mulexml:object-to-xml-transformer doc:name="Object to XML"/>
        <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5"  doc:name="XSLT" xsl-file="xslt/request.xsl">
        <mulexml:context-property key="outboundVendorId" value='#[header:INBOUND:vendorid]'>
       
        </mulexml:context-property>
        </mulexml:xslt-transformer>
   <cxf:jaxws-client operation="VendorGet" clientClass="com.oracle.xmlns.enterprise.tools.services.testvendorrecordciservice_1.TestVendorRecordCIService" port="CI_H_CI_WS_TEST_Port" wsdlLocation="wsdl/CI_H_CI_WS_TEST.1.wsdl" enableMuleSoapHeaders="true" doc:name="SOAP">
            <cxf:ws-security>
                <cxf:ws-config>
                </cxf:ws-config>
            </cxf:ws-security>
            <cxf:jaxb-databinding/>
        </cxf:jaxws-client>
        <http:outbound-endpoint exchange-pattern="request-response"
                        host="${host.url}"
                        path="${path}" doc:name="HTTP" method="GET" port="7011"  password="${password}" user="${username}">
                         <message-properties-transformer scope="outbound">
               
                <add-message-property key="outboundVendorId" value="#[header:INBOUND:vendorid]"/>
            </message-properties-transformer>
                </http:outbound-endpoint>
        <logger level="INFO" doc:name="Logger" message=" #[payload]"/>
        <catch-exception-strategy doc:name="Catch Exception Strategy">
        <processor-chain doc:name="Processor Chain">
            <logger message="Exception_logger" level="INFO" doc:name="Exception_logger" />
            <custom-transformer class="org.hhmi.CustomExceptionHandler" doc:name="Java"/>
            <logger message="Exception_logger" level="INFO" doc:name="Exception_logger" />
        </processor-chain>
    </catch-exception-strategy>
    </flow>