I am new to FreeMarker language. What I am trying to do is to create a http request with soap envelope to grab the data back from the Third party server. I have a question about the "Escape sequence" in there.
For instance, I have a variable in my FreeMarker like
<#assign soap_env="<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<ns7:ClientInfoHeader soapenv:mustUnderstand="0" xmlns:ns7="urn:messages.ws.rightnow.com/v1.1">
<ns7:AppID>Run report sample</ns7:AppID>
</ns7:ClientInfoHeader>
<wsse:Security mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken><wsse:Username>${login}</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">${Liu@8275?}</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header> <soapenv:Body>
<ns7:RunAnalyticsReport xmlns:ns7="urn:messages.ws.rightnow.com/v1.1">
<ns7:AnalyticsReport xsi:type="ns4:AnalyticsReport" xmlns:ns4="urn:objects.ws.rightnow.com/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID id="146682" xmlns="urn:base.ws.rightnow.com/v1.1"/>
</ns7:AnalyticsReport><ns7:Limit>1000</ns7:Limit><ns7:Start>0</ns7:Start>
</ns7:RunAnalyticsReport> </soapenv:Body> </soapenv:Envelope> ">
Do I need to replace all the quotation to another format? if yes, can you please give me an example?
Freemarker Escape sequence Meaning
\" Quotation mark (u0022)
\' Apostrophe (a.k.a. apostrophe-quote) (u0027)
\\ Back slash (u005C)
\n Line feed (u000A)
\r Carriage return (u000D)
\t Horizontal tabulation (a.k.a. tab) (u0009)
\b Backspace (u0008)
\f Form feed (u000C)
\l Less-than sign: <
\g Greater-than sign: >
\a Ampersand: &
\xCode Character given with its hexadecimal Unicode code (UCS code)
如果您的意思是<#assign soap_env='<someXml someAttributes="someValue" />'>
,如本例所示,则应使用两个不同的引号( '
和"
),因此FreeMarker不会对于字符串文字的结尾感到困惑,或者,您也可以使用转义,例如<#assign soap_env="<someXml someAttributes=\\"someValue\\" />">
,但这<#assign soap_env="<someXml someAttributes=\\"someValue\\" />">
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.