Problem with XSLT Transformation when used with a Proxy Service

mattshaw's picture

Hi,

I've create a web service proxy which adds some content to the Response send back to the client.  I am doing this with an XSLT mediator.  When the XSLT is very simple everything seems to work OK.  However when I try to use a slightly more complicated XSLT the transformation is seemingly not performed but there are no errors generated that I can see.  I have tried running the XSLT using Altova XMLSpy and the Xalan 2.7.0 library directly and they transform the document as expected.  How can I debug this issue or could you let me know how to resolve this issue ?  I have included the XSLT stylesheet, the Response that I am trying to transform and the ESB config file.

I am running on Windows XP SP1, Java 1.5.0_10, Mozilla Firefox 2.0.0.9.

Many Thanks

Matt Shaw

I've had to change the name/extension of the stylesheet to upload.

AttachmentSize
SourceData.xml353 bytes
AddXMLHeaderAndBody.xml2.25 KB
axis2.xml18.02 KB
ruwan's picture

Can you attach the synapse.xml

Hi Matt, You have attached the axis2.xml which is not the synapse configuration, can you please attach the synapse.xml file resides in the same folder. At the same time can you enable the synapse DEBUG log and attach the log out put as well (You can change the org.apache.synapse log level from INFO to DEBUG in the log4j.properties file found at webapp/WEB-INF/classes/conf folder in order to achieve this) But I do not see any issue if the XSLT is working when it is simple. Thanks, Ruwan Linton
mattshaw's picture

Here are the file

Hi, Thanks for getting back to me so quickly. Here are the files as requested. Best regards Matt Shaw  
ruwan's picture

Another request on trace

Hi Matt, Sorry, but I can not figure out what is wrong even with the DEBUG log. Can you change the TRACE_APPENDER log level to TRACE and send the trace log. (i.e. you have to change the entry "log4j.category.TRACE_LOGGER=INFO," to TRACE and sent me the trace.txt file) Thanks,   Ruwan Linton
mattshaw's picture

The result of the increased TRACE

Hi, One thing I did notice in the Trace log was that the "Message" was the complete message as expected, but the "Transformation source" was only the data within the Body tag and therefore the Transformation result was also only the data within the body.  The XSLT that I am using matches the Body tag to do the transformation.  Is this the issue ? i.e. the the whole message is not being passed to the processor only the payload within the Body tag ? This will cause me an issue as I may also need to add a Header tag at some stage. Do you still need the trace file ? Best regards Matt Shaw
ruwan's picture

No need of the trace

Hi Matt, OK, I got the problem. No need of the trace, In the XSLT mediator you have only specified the XSLT key, in which case the transformation source will be taken as the soap payload which is the first element inside the Body. If you want to pass the whole envelope you need to specify the source attribute as the XPath to the full Envelope, to the XSLT mediator. So the resulting configuration for the XSLT mediator will be as follows, <syn:xslt xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" key="XSLT/AddMoDXMLHeaderAndBody.xslt" source="//s11:Envelope | //s12:Envelope"/> I have included both the soap11 and soap12 Envelopes in order to keep the consistency. If you are only using SOAP11 or 12, you can go with the appropriate XPATH. but it is recomended to keep it generic to support both versions. Thanks,   Ruwan Linton
mattshaw's picture

Thanks

Hi Ruwan, Thanks for sorting that out so quickly it is much appreciated.  I'll try that fix tomorrow and let you know. On a seperate issue I raised on another forum topic asankha told me to ask you for an answer to a question I have regarding the smtp mail end point.  I have the SMTP mail end point working so I can get it to send out emails but is it possible through the configuration to change things such as the subject line, address from and whether the content is an attachment or in the main body of the email ? Many thanks Matt  
ruwan's picture

Replied to you on the other thread

Matt, I have replied to you on the other thread regarding the mail transport configurations. Unfortunately it is not that flexible except for the From header, since it is to deel with SOAP messages. We might need to think of a Generic mail transport for ESB. Thanks, Ruwan Linton
mattshaw's picture

Hi Ruwan, I have now had a

Hi Ruwan, I have now had a chance to test the changes that you suggested.  It has got further but is still not working. Looking at the trace log it now seems that the Transformation source is correct with the full XML document from the Envelope element down.  This gets passed to the transformation and the Transformation result is now correct with my new elements inserted into the Body element. However when the Send mediator starts, the message it's using hasn't got my changes in it and it looks like the original message. Any thoughts ? Best regards Matt  
mattshaw's picture

In addition to the problem

Hi, I have now tested the XSLT Transformation where the transformation takes place using elements within the Body so that I don't have to specify a source attribute.  This works fine.  So the issue seems to be if your transformation requires you to match a pattern and modify the XML using either the Body or Envelope tags it won't send out that result.  The transformation seems to work but the Send mediator sends out the original message ? Any help would be much appreciated ? Matt  
ruwan's picture

That is an issue

Hi Matt, I found that this is an issue of the XSLT mediator and I have filed a JIRA [1] on this and I will try my best to fix this by the early next week. BTW: if what you want is just to add a SOAP header, then you could have used the header mediator as well. [1] - https://issues.apache.org/jira/browse/SYNAPSE-187 Thanks, Ruwan Linton
mattshaw's picture

Thanks for your speedy response

Thanks Ruwan, I appreciate your speedy response. Matt
ruwan's picture

It seems a limitation

Hi Matt, I have tried my best to support this scenario but it seems a limitation of the XSLT mediator please see my comment on the JIRA [1] [1] - https://issues.apache.org/jira/browse/SYNAPSE-187   Ruwan Linton
mattshaw's picture

Thanks for your help

Hi Ruwan, Thanks for looking into it so quickly.  You have a valid point I'll structure the XSLT to cope with this scenario. Many Thanks Matt Shaw