You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Michael Griffin <mg...@fsenablers.com> on 2007/02/09 22:41:46 UTC
FW: XSLTMediator problem?
-----Original Message-----
From: Asankha C. Perera [mailto:asankha@wso2.com]
Sent: Friday, February 09, 2007 3:57 AM
To: Michael Griffin
Subject: Re: XSLTMediator problem?
Hi Griffin
Could you get me a sample reply from your actual service endpoint as well?
If these sample messages/transforms are not confidential, I would urge you
to post this into the synapse-dev list, so that others may also have a
chance to reply to you as I will be traveling to the US early morning
tomorrow my time
asankha
Michael Griffin wrote:
Asanka,
I am using the 0.91 release. Here is the contents of synapse.xml
<synapse xmlns="http://ws.apache.org/ns/synapse">
<registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
<property name="root" value="file:repository/conf/sample/resources/"/>
<property name="cachableDuration" value="15000"/>
</registry>
<definitions>
<set-property name="OrderStatusUpdateResponse.xslt"
key="transform/updateOrderStatusResponse.xslt"/>
<endpoint name="myEndPoint"
address="http://hostname/services/myservice"/>
</definitions>
<rules>
<log level="full"/>
<in>
<send><endpoint ref="myEndPoint"/></send>
</in>
<out>
<xslt key="OrderStatusUpdateResponse.xslt"/>
<send/>
</out>
</rules>
</synapse>
Here is my style sheet
<xsl:transform
xmlns:fse-internal="http://services.fsenablers.com/orderStatus"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.fsenablers.com/v2"
exclude-result-prefixes="fse-internal"
version="2.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="text()|@*"/>
<xsl:template match="fse-internal:updateOrderStatusReturn">
<uosr>
<sc><xsl:value-of select="fse-internal:statusCode"/></sc>
<msg><xsl:value-of select="fse-internal:message"/></msg>
</uosr>
</xsl:template>
<xsl:template match="fse-internal:updateOrderStatusResponse">
<response>
<xsl:apply-templates select="*"/>
</response>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="//fse-internal:updateOrderStatusReturn"/>
</xsl:template>
</xsl:transform>
And here is an actual response recieved by the client code
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns2:state soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0"
xmlns:ns2="http://services.fsenablers.com/orderStatus">good</ns2:state>
</soapenv:Header>
<soapenv:Body>
<updateOrderStatusResponse
xmlns="http://services.fsenablers.com/orderStatus">
<updateOrderStatusReturn>
<message>The message</message>
<statusCode>OK</statusCode>
</updateOrderStatusReturn>
</updateOrderStatusResponse>
<uosr xmlns="http://www.fsenablers.com/v2">
<sc>OK</sc>
<msg>The message</msg>
</uosr>
</soapenv:Body>
</soapenv:Envelope>
-----Original Message-----
From: Asankha C. Perera [mailto:asankha@wso2.com]
Sent: Thursday, February 08, 2007 9:12 AM
To: synapse-user@ws.apache.org
Subject: Re: XSLTMediator problem?
Hi Griffin
Can you confirm that you are using 0.91 release? also, is it possible
for you to share your XSLT and configuration with us? I will look into
this and get back to you.. but if the above is available, it would be
quicker for me to try and reproduce this.
asankha
Michael Griffin wrote:
Hi,
I'm new to Synapse but it seems like a great project. After working
through
some of the samples, I tried to transform the response from an existing
web
service. The problem I ran into was that my SOAP body on the return
contained both the original contents plus the transformed contents. So
something like this....
...
<soapenv:Header>
<ns2:state
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0" xmlns:ns2="old-namespace">good</ns2:state>
</soapenv:Header>
<soapenv:Body>
<response xmlns="old-namespace">
<status>status</status>
<message>a message</message>
</responser>
<resp xmlns="new-namespace">
<sc>status</sc>
<msg>a message</msg>
</res>
</soapenv:Body>
...
Has anyone else run into this problem? Is there a way around it. I've
verified that my style sheet is working correctly, and the debug output
from
synapse indicates that the result of the transformation is correct.
I did some poking around with the source and found that
XSLTMediator.performXLST handles the merge of the result back in to the
source document in two different ways - if the parent was a SOAPEnvelope
(uses setFirstOMChild) and the other (addChild) if it is not. With some
experimentation I can perform and additional test to see if the parent is
a
SOAPBody and use setFirstOMChild accordingly - this results in a proper
replacement of the source with the transformed elements.
Thoughts?
Thanks
Griffin
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org