insert node to empty SOAP message

heng005.hotmail.com's picture
i want to insert a element called result into an empty SOAP message. so i create a XSLT transform but i'm very new to XSLT. input SOAP: <?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body /> </soapenv:Envelope> expected output: <?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <result>aaa</result> </soapenv:Body> </soapenv:Envelope> my xslt is: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <result>aaaa</result> </xsl:template> </xsl:stylesheet> my XSLT transform is: <xslt key="addResultXSLT" /> i don't config the Source attribute. i found an error like this: ERROR XSLTMediator Unable to perform XSLT transformation using : addResultXSLT against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1] java.lang.NullPointerException at org.apache.synapse.util.jaxp.StreamSourceBuilder.getSource(StreamSourceBuilder.java:56) Can you suggest what is wrong? what is the best way to insert a node to SOAP message, XSLT? Which part of an empty SOAP message is selected, if i don't config the source attribute of XSLT mediator? Thank you in advance
heng005.hotmail.com's picture

i used my XSLT to transform

i used my XSLT to transform the CheckPriceRequest (sample 8) and it work properly. i got the expected output: <?xml version='1.0' encoding='utf-8'?> <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:C23AF1E9E2A3A2AD5F1280713663949</wsa:MessageID> <wsa:Action>urn:getQuote</wsa:Action> </soapenv:Header> <soapenv:Body> <result>aaaa</result> </soapenv:Body> </soapenv:Envelope> Does my problem occur because of an empty SOAP Body? and what should the xsl file be?
rajika's picture

You can also take a look at

You can also take a look at the enrich mediator to see how it can use for your purpose. Rajika
heng005.hotmail.com's picture

thanks

Thank you, Rajika. are there any manual for enrich mediator. i can't find any of them in the configuration language page.
heng005.hotmail.com's picture

document found

i've found help of enrich mediator in wso2 admin page. thanks heng
heng005.hotmail.com's picture

how to use enrich mediator

after i've read all of manual page of enrich mediator. https://10.99.0.227:9443/carbon/enrich-mediator/docs/userguide.html http://wso2.org/project/esb/java/3.0.0/docs/mediators/enrich.html i still don't know how to use it. can you please give me a short example. how to set the enrich mediator if i want to add a part of xml (foo) into an empty SOAP body. i think the WSO2 3.0.0 interface cannot handle all of the enrich mediator's options, such as inline text or property. Thank you. heng
werdex86.yahoo.com's picture

Hi! I am also interested in

Hi! I am also interested in enrich mediator. I was not able to find any samples except configuration doc. I am trying to do the following: 1) Assume we have the following soap request:      <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">     <soapenv:Body>        <ns1:fireEvent xmlns:ns1="http://test.com">          <ns1:message>HI THERE</ns1:message>        </ns1:fireEvent>     </soapenv:Body>   </soapenv:Envelope> And i have a string property in message context called 'myMessage' : <test>HI</test> How insert myMessage string as xml to message tag using enrich mediator? The result should be:     <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">     <soapenv:Body>        <ns1:fireEvent xmlns:ns1="http://test.com">          <ns1:message><test>HI</test></ns1:message>        </ns1:fireEvent>     </soapenv:Body>   </soapenv:Envelope> 2) The same as 1 but 'myMessage'  should be set as text content:     <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">     <soapenv:Body>        <ns1:fireEvent xmlns:ns1="http://test.com">          <ns1:message>&lt;test>HI&lt;/test></ns1:message>        </ns1:fireEvent>     </soapenv:Body>   </soapenv:Envelope> 3) Is it possible to insert text content from registry to tag(the same way as 1 and 2)? Thx for help!
werdex86.yahoo.com's picture

I have looked at sources of

I have looked at sources of EnrichMediator. 1) In my case to achieve this i need at first to convert string to OMElement. I have choosed to use JS Mediator:    <script language="js"><![CDATA[             var content=  mc.getProperty('myContent');             var contentElement=  Packages.org.apache.axiom.om.impl.llom.util.AXIOMUtil.stringToOM(content);             mc.setProperty('myContent',contentElement);             ]]></script>     <enrich xmlns="http://ws.apache.org/ns/synapse">                 <source clone="true" type="property" property="myContent"/>                 <target action="child" type="custom" xpath="$body/ns1:fireEvent/ns1:message"                         xmlns:ns1="http://test.com"/>             </enrich> 2) Not possible via enrich mediator. Need to manipulate with nodes in JS mediator using AxiomXPath as described at http://wso2.org/library/265 3) I have not found how to set registry string content to property. One of the solution is to use getEntryDefinition in JS mediator and convert InputStream to String by hand. If i do smth wrong,please correct me. Thx.  
hareeshhyd.yahoo.com's picture

Here is the solution

http://wso2.org/forum/thread/11286
micg.ipp.mpg.de's picture

are there any plans to

are there any plans to improve the enrich mediator, so that it can solve the second scenario pointed by werdex? (insert text content into a given message tag) Another problem is that the Enrich Mediator only works with single notes. for example if you have:   <coordinates> <x>1</x> <x>1.1</x> <y>0.9</y> <y>0.99</y> <z>0</z> <z>1</z> </coordinates> you can't take all x, y and z's with the XPath 'coordinates/*' and copy them into an other message. it would be really nice to have because It seems that 75% of my enrich cases need such functionality...  
indika's picture

Please create a JIRA. We have

Please create a JIRA. We have done some improvements to the enrich mediator in the current trunk, will consider the issue pointed out for the next release ~ Indika
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)