lvzhiliang 2014-12-24
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