Discussion:
Transform rest request to soap body
benny boy
2010-12-29 15:52:39 UTC
Permalink
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
David Dossot
2010-12-29 16:03:31 UTC
Permalink
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
Post by benny boy
Hello,
I'm making my first steps on mule 2.2, trying to convert an http request to
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.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
benny boy
2010-12-29 16:25:28 UTC
Permalink
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
David Dossot
2010-12-29 16:43:39 UTC
Permalink
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" <mule.user.relay-***@public.gmane.org> 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...
benny boy
2010-12-29 17:50:22 UTC
Permalink
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
David Dossot
2010-12-29 17:55:00 UTC
Permalink
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<http://johndemic.blogspot.com/2009/04/mule-saaj-transport.html>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
Post by benny boy
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)
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
benny boy
2010-12-29 19:47:12 UTC
Permalink
Thanks a lot , i'll give the groovy transformer a try.

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

http://xircles.codehaus.org/manage_email
David Dossot
2010-12-29 19:56:40 UTC
Permalink
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
Post by benny boy
Thanks a lot , i'll give the groovy transformer a try.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
benny boy
2010-12-30 13:55:10 UTC
Permalink
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
David Dossot
2010-12-30 15:40:55 UTC
Permalink
Congrats, you've learned quite a few tricks :)


On Thu, Dec 30, 2010 at 5:55 AM, benny boy
Post by benny boy
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.
---------------------------------------------------------------------
http://xircles.codehaus.org/manage_email
xcepttj
2013-10-15 19:46:43 UTC
Permalink
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
***@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 ***@4196c169



--
View this message in context: http://mule.1045714.n5.nabble.com/Transform-rest-request-to-soap-body-tp3321454p5719025.html
Sent from the Mule - User mailing list archive at Nabble.com.

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

http://xircles.codehaus.org/manage_email
xcepttj
2013-10-16 12:51:44 UTC
Permalink
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>



--
View this message in context: http://mule.1045714.n5.nabble.com/Transform-rest-request-to-soap-body-tp3321454p5719029.html
Sent from the Mule - User mailing list archive at Nabble.com.

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

http://xircles.codehaus.org/manage_email

Continue reading on narkive:
Loading...