On Sat, Sep 15, 2012 at 5:19 PM, Hiranya Jayathilaka
<[email protected]>wrote:

> I don't know for sure whether this problem can be solved. But sometime
> back I wrote a custom mediator to do XSLT transformations using the StAX
> support available in the Java TrAX API. It showed a fairly good performance
> improvement against the existing implementation too.
>
> Solving the problem mentioned in this thread will be pretty hard. Perhaps
> we can relax the conditions a bit. We can wrap the output of the
> transformation in a SOAP envelope and put that back in the data handler. We
> will use
>

s/use/loose/


> any information in the original SOAP headers, but that won't be an issue
> for most practical scenarios.
>
> Thanks,
> Hiranya
>
> On Sat, Sep 15, 2012 at 9:23 AM, Andun Sameera <[email protected]> wrote:
>
>> Hi Amila,
>>
>> On Sat, Sep 15, 2012 at 9:22 PM, Amila Suriarachchi <[email protected]>wrote:
>>
>>> Does xslt engine supports xml stream level transformations?
>>
>>
>> Yes. But not 100% streams, but we can transform StreamSource object to
>> a StreamResult using the Transformer.
>>
>>
>>> After xslt transformations users may want to do further processing with
>>> the message. So in that case we can avoid building request Axiom object but
>>> may required to create the transformed Axiom object.
>>>
>>
>> Yes your argument is correct, sometimes we have to create the result
>> message. But I got in to trouble even before. In the present scenario, XSLT
>> mediator  read some parameters from the request using AXIOM. It read
>> weather transformation is happening to SOAP body or SOAP envelop etc. Based
>> on those parameters after the transformation mediator reform the message.
>> You can fine that logic in 
>> [1]<http://wso2.org/svn/browse/wso2/carbon/platform/branches/4.0.0/dependencies/synapse/2.1.0-wso2v7/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java?view=markup>
>> .
>>
>> But here I have no such parameters, I have only a input stream and
>> I transform it using the XSLT file. After transformation I have no clue
>> to reform the message. What I do is set the output stream to
>> the data-handler in binary relay dummy message. So some parts of the
>> original message get dropped and everything crashes here after.
>>
>>
>>> thanks,
>>> Amila.
>>>
>>>
>>> On Sat, Sep 15, 2012 at 4:16 PM, Andun Sameera <[email protected]> wrote:
>>>
>>>> Hi All,
>>>>
>>>> My requirement is $Subject. Purpose of this is avoid using AXIOM to to
>>>> XSLT transformation. Our plan was to do all the transformation using Input,
>>>> Output Streams. javax.xml.transform.Transformer is used to do
>>>> the transformation using streams. I developed the mediator using
>>>> the following logic,
>>>>
>>>>
>>>>    - In the Binary Relay We get the Message as a Data Handler in a
>>>>    Dummy SOAP Message. From that we can get a Input Stream for the SOAP
>>>>    message which needs to be transformed using XSLT.
>>>>    - We can Get the input Stream for the XSLT file, which is in
>>>>    registry or local.
>>>>    - Using those two we can do the XSLT transformation. As a result we
>>>>    get a stream for the transformed SOAP message.
>>>>    - Finally I create a DataHandler using the stream and attached it
>>>>    to the Relay's Dummy SOAP message replacing existing one.
>>>>
>>>> The output of the mediator follows this logic is given below. I used
>>>> the Sample 
>>>> 8<http://wso2.org/project/esb/java/4.0.3/docs/samples/message_mediation_samples.html#Sample8>of
>>>>  ESB. I replaced the XSLT mediator with my custom mediator in the Binary
>>>> Relay.
>>>> But there is a major problem here. Because of the logic we used the
>>>> original SOAP message,
>>>>
>>>> <soapenv:Envelope xmlns:soapenv="
>>>> http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Header xmlns:wsa="
>>>> http://www.w3.org/2005/08/addressing";><wsa:To>
>>>> http://localhost:9000/services/SimpleStockQuoteService</wsa:To><wsa:MessageID>urn:uuid:0f7403b4-c5bc-4347-8921-562f2736a2ab</wsa:MessageID><wsa:Action>urn:getQuote</wsa:Action></soapenv:Header><soapenv:Body><m0:CheckPriceRequest
>>>> xmlns:m0="http://services.samples
>>>> "><m0:Code>IBM</m0:Code></m0:CheckPriceRequest></soapenv:Body></soapenv:Envelope>
>>>>
>>>>  is now converted to.
>>>>
>>>> <m:getQuote xmlns:m="http://services.samples";>
>>>>    <m:request>
>>>>       <m:symbol>IBM</m:symbol>
>>>>    </m:request>
>>>> </m:getQuote>
>>>>
>>>> At the end Binary Relay Formatter will read the DataHandler and above
>>>> SOAP message will be sent to the AXIS2 Server and It will crash, because
>>>> this is not a valid SOAP message.
>>>> This problem occurs because we are not using AXIOM anymore. In the
>>>> normal XSLT mediator it
>>>> uses org.apache.synapse.util.xpath.SourceXPathSupport class to find the
>>>> part of the message which transformed using XSLT. So it can replace
>>>> the transformed part of the original message. But here we cant use that
>>>> kind of a logic. Because we use only streams. We cant build OMElements or
>>>> etc.
>>>>
>>>> Need help to solve this problem. The custom mediator java files are
>>>> attached here.
>>>>
>>>> Thanks
>>>> AndunSLG
>>>>
>>>> References :
>>>>
>>>> [1] -
>>>> http://wso2.org/project/esb/java/4.0.3/docs/samples/message_mediation_samples.html#Sample8
>>>>
>>>>
>>>> Console Output for the Custom Mediator :
>>>>
>>>> .....................Original SOAP Envelop..........................
>>>> <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="
>>>> http://www.w3.org/2003/05/soap-envelope";><soapenv:Body><ns:binary
>>>> xmlns:ns="http://ws.apache.org/commons/ns/payload
>>>> ">PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48c29hcGVudjpFbnZlbG9wZSB4bWxuczpzb2FwZW52PSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VudmVsb3BlLyI+PHNvYXBlbnY6SGVhZGVyIHhtbG5zOndzYT0iaHR0cDovL3d3dy53My5vcmcvMjAwNS8wOC9hZGRyZXNzaW5nIj48d3NhOlRvPmh0dHA6Ly9sb2NhbGhvc3Q6OTAwMC9zZXJ2aWNlcy9TaW1wbGVTdG9ja1F1b3RlU2VydmljZTwvd3NhOlRvPjx3c2E6TWVzc2FnZUlEPnVybjp1dWlkOjBmNzQwM2I0LWM1YmMtNDM0Ny04OTIxLTU2MmYyNzM2YTJhYjwvd3NhOk1lc3NhZ2VJRD48d3NhOkFjdGlvbj51cm46Z2V0UXVvdGU8L3dzYTpBY3Rpb24+PC9zb2FwZW52OkhlYWRlcj48c29hcGVudjpCb2R5PjxtMDpDaGVja1ByaWNlUmVxdWVzdCB4bWxuczptMD0iaHR0cDovL3NlcnZpY2VzLnNhbXBsZXMiPjxtMDpDb2RlPklCTTwvbTA6Q29kZT48L20wOkNoZWNrUHJpY2VSZXF1ZXN0Pjwvc29hcGVudjpCb2R5Pjwvc29hcGVudjpFbnZlbG9wZT4=</ns:binary></soapenv:Body></soapenv:Envelope>
>>>>
>>>> ................................................................................
>>>>
>>>> .....................Original SOAP Message........................
>>>> <soapenv:Envelope xmlns:soapenv="
>>>> http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Header xmlns:wsa="
>>>> http://www.w3.org/2005/08/addressing";><wsa:To>
>>>> http://localhost:9000/services/SimpleStockQuoteService</wsa:To><wsa:MessageID>urn:uuid:0f7403b4-c5bc-4347-8921-562f2736a2ab</wsa:MessageID><wsa:Action>urn:getQuote</wsa:Action></soapenv:Header><soapenv:Body><m0:CheckPriceRequest
>>>> xmlns:m0="http://services.samples
>>>> "><m0:Code>IBM</m0:Code></m0:CheckPriceRequest></soapenv:Body></soapenv:Envelope>
>>>>
>>>> ................................................................................
>>>>
>>>> Transforming On Progress.....
>>>>
>>>> ...................Transformed SOAP Message...................
>>>> <m:getQuote xmlns:m="http://services.samples";>
>>>>    <m:request>
>>>>       <m:symbol>IBM</m:symbol>
>>>>    </m:request>
>>>> </m:getQuote>
>>>>
>>>> ..............................................................................
>>>>
>>>> ...................Transformed SOAP Envelop..................
>>>> <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="
>>>> http://www.w3.org/2003/05/soap-envelope";><soapenv:Body><ns:binary
>>>> xmlns:ns="http://ws.apache.org/commons/ns/payload
>>>> ">PG06Z2V0UXVvdGUgeG1sbnM6bT0iaHR0cDovL3NlcnZpY2VzLnNhbXBsZXMiPgogICA8bTpyZXF1ZXN0PgogICAgICA8bTpzeW1ib2w+SUJNPC9tOnN5bWJvbD4KICAgPC9tOnJlcXVlc3Q+CjwvbTpnZXRRdW90ZT4K</ns:binary></soapenv:Body></soapenv:Envelope>
>>>>
>>>> ..............................................................................
>>>>
>>>>
>>>
>>>
>>> --
>>> *Amila Suriarachchi*
>>>
>>> Software Architect
>>> WSO2 Inc. ; http://wso2.com
>>> lean . enterprise . middleware
>>>
>>> phone : +94 71 3082805
>>>
>>>
>> Any suggestions to overcome this problem ?
>>
>> Thanks
>> AndunSLG
>>
>> [1]
>> http://wso2.org/svn/browse/wso2/carbon/platform/branches/4.0.0/dependencies/synapse/2.1.0-wso2v7/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java?view=markup
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Hiranya Jayathilaka
> Mayhem Lab/RACE Lab;
> Dept. of Computer Science, UCSB;  http://cs.ucsb.edu
> E-mail: [email protected] <[email protected]>;  Mobile: +1 (805) 895-7443
> Blog: http://techfeast-hiranya.blogspot.com
>



-- 
Hiranya Jayathilaka
Mayhem Lab/RACE Lab;
Dept. of Computer Science, UCSB;  http://cs.ucsb.edu
E-mail: [email protected] <[email protected]>;  Mobile: +1 (805) 895-7443
Blog: http://techfeast-hiranya.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to