« Return to Thread: [Dev] apache synapse javascript ecoding problem
Hi Paul,i want to add logic in javascript code, for example;<script language="js"><![CDATA[var city_Code = mc.getPayloadXML()..*::cityCodeto.toString();
var city_Name = mc.getPayloadXML()..*::cityName.toString();
var limit_From = mc.getPayloadXML()..*::limitFrom.toString();var soapBody = "";
var limit_To = mc.getPayloadXML()..*::limitTo.toString();
if(city_Name!="null") soapBody = "<p:cityName xmlns:p=\"http://ws.wso2.org/dataservice\">" +city_Name+"</p:cityName>";
if(city_Code!="null") soapBody = "<p:cityCode xmlns:p=\"http://ws.wso2.org/dataservice\">" +city_Code+"</p:cityCode>";
soapBody = "<p:limitFrom xmlns:p=\"http://ws.wso2.org/dataservice\">" +limit_From+"</p:limitFrom>"
+ "<p:limitTo xmlns:p=\"http://ws.wso2.org/dataservice\">" +limit_To+"</p:limitTo>";
mc.setPayloadXML(
<p:optGetCity xmlns:p="http://ws.wso2.org/dataservice">
{soapBody}
</p:optGetCity>);]]>
</script>from this requirement(if value equal null element not sending) my code must bu like.ErcanIts because you are using the {} syntax to embed a string into an XML.If you make a single XML and just use {} to embed the variables (city_Name) etc, then it should work fine. If you notice, the <p:optGetCity> is coming out fine.e.g.mc.setPayloadXML(
<p:optGetCity xmlns:p="http://ws.wso2.org/dataservice">
<p:limitFrom> {limit_From}</p:limitFrom>
</p:optGetCity>);]]>
</script>PaulOn 16 April 2012 08:55, Ercan Can <canercan04@...> wrote:
Hi everybody,<script language="js"><![CDATA[
var city_Name = mc.getPayloadXML()..*::cityName.toString();var limit_From = mc.getPayloadXML()..*::limitFrom.toString();var soapBody = "<p:limitFrom xmlns:p=\"http://ws.wso2.org/dataservice%5C">" +limit_From+"</p:limitFrom>"
var limit_To = mc.getPayloadXML()..*::limitTo.toString();
+ "<p:limitTo xmlns:p=\"http://ws.wso2.org/dataservice\">" +limit_To+"</p:limitTo>";
mc.setPayloadXML(
<p:optGetCity xmlns:p="http://ws.wso2.org/dataservice">
{soapBody}
</p:optGetCity>);]]>
</script>this script was there in esb proxy, when i runnig proxy service everthing is ok, proxy send soap body to dss and message like this<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<p:optGetCity xmlns:p="http://ws.wso2.org/dataservice"><p:limitFrom xmlns:p="http://ws.wso2.org/dataservice">0</p:limitFrom><p:limitTo xmlns:p="http://ws.wso2.org/dataservice">100</p:limitTo></p:optGetCity>
</soapenv:Body>
</soapenv:Envelope>'<' character encoded to '<', how can i resolve this problem.Thanks a lot.
_______________________________________________
Dev mailing list
Dev@...
http://wso2.org/cgi-bin/mailman/listinfo/dev
--
Paul Fremantle
CTO and Co-Founder, WSO2
OASIS WS-RX TC Co-chair, VP, Apache Synapse
UK: +44 207 096 0336
US: +1 646 595 7614
blog: http://pzf.fremantle.org
twitter.com/pzfreo
paul@...wso2.com Lean Enterprise Middleware
Disclaimer: This communication may contain privileged or other confidential information and is intended exclusively for the addressee/s. If you are not the intended recipient/s, or believe that you may have received this communication in error, please reply to the sender indicating that fact and delete the copy you received and in addition, you should not print, copy, retransmit, disseminate, or otherwise use the information contained in this communication. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.
« Return to Thread: [Dev] apache synapse javascript ecoding problem
| Free embeddable forum powered by Nabble | Forum Help |