AXIS 1.4 服务端特殊字符不转义(比如CDATA区域,研究了好久)
import java.io.PrintWriter; import javax.servlet.http.HttpServletResponse; import org.apache.axis.Message; import org.apache.axis.MessageContext; import org.apache.axis.message.SOAPEnvelope; import org.apache.axis.transport.http.HTTPConstants; public class Service01 { public String service(String name) throws Exception { // String a = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><soapenv:Body><GetPasswordServiceApplyResponse xmlns=\"http://getpassword.server.interfaces.lcunp.linkage.com\"><GetPasswordServiceApplyReturn><description>TimeStamp is wrong</description><resultCode>5</resultCode><userName>agagagag</userName></GetPasswordServiceApplyReturn></GetPasswordServiceApplyResponse></soapenv:Body></soapenv:Envelope>"; //Thread.sleep(10000); System.out.println(name); MessageContext mc = MessageContext.getCurrentContext(); // Message msg = new Message("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></soapenv:Envelope>",true); Message msg = new Message("<wangfeng>&abc"); mc.setResponseMessage(msg); // mc.reset(); // HttpServletResponse response = (HttpServletResponse) mc.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE); // response.setContentType("text/xml;charset=utf-8"); // PrintWriter pw = response.getWriter(); // pw.write("<wangfeng>"); // pw.flush(); // throw new Exception(); return null; } }
这时候<符号不会被转义成为<
用soapui测试结果如下:
HTTP/1.1200OK
Server:Apache-Coyote/1.1
Set-Cookie:JSESSIONID=CF5C49618724F725227A6B96C189FD55;Path=/axis
Content-Type:text/xml;charset=utf-8
Transfer-Encoding:chunked
Date:Wed,24Dec201409:02:19GMT
<?xmlversion="1.0"encoding="UTF-8"?><wangfeng>&abc
相关推荐
mmmjyjy 2020-07-16
千锋 2020-07-04
jzlixiao 2020-05-04
babycrying 2009-12-11
zhangxiaojiakele 2020-01-07
lybbb 2019-12-25
newfarhui 2019-12-12
jiahaohappy 2019-12-04
BETTINA 2019-12-02
jianghuchuanke 2019-11-03
morexyoung 2019-11-01
Selier 2014-05-28
javaer 2016-12-06
kx0 2019-04-29
xiajlxiajl 2015-09-01
xiajlxiajl 2013-01-25
82580194 2015-06-13