Methods Summary |
---|
private javax.xml.soap.SOAPMessage | createMessageFromInputStream(java.io.InputStream is)
MessageFactory mf = MessageFactory.newInstance();
return mf.createMessage(new MimeHeaders(), is);
|
private javax.xml.soap.SOAPMessage | createTestMessage()
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage msg = mf.createMessage();
SOAPBody sb = msg.getSOAPBody();
SOAPElement se1 = sb.addChildElement("echoString", "ns1", "http://tempuri.org");
SOAPElement se2 = se1.addChildElement("string");
se2.addTextNode(textValue);
return msg;
|
private void | testEncoding(java.lang.String encoding)
SOAPMessage msg = createTestMessage();
msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
msg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, encoding);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
msg.writeTo(baos);
String msgString = new String(baos.toByteArray(), encoding);
System.out.println("msgString (" + encoding + ")=" + msgString);
assertTrue(msgString.startsWith("<?xml version=\"1.0\" encoding=\"" + encoding + "\""));
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
SOAPMessage msg1 = createMessageFromInputStream(bais);
SOAPElement se1 = (SOAPElement) msg1.getSOAPBody().getChildElements().next();
SOAPElement se2 = (SOAPElement) se1.getChildElements().next();
Text text = (Text)se2.getChildElements().next();
assertEquals(textValue, text.getValue());
|
public void | testEncodingPropertyUTF16()
testEncoding("UTF-16");
|
public void | testEncodingPropertyUTF8()
testEncoding("UTF-8");
|
public void | testWriteXmlDeclPropertyFalse()
testXmlDecl("false", "<soapenv:Envelope");
|
public void | testWriteXmlDeclPropertyTrue()
testXmlDecl("true", "<?xml");
|
private void | testXmlDecl(java.lang.String xmlDecl, java.lang.String expected)
SOAPMessage msg = createTestMessage();
msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, xmlDecl);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
msg.writeTo(baos);
String msgString = new String(baos.toByteArray(), "UTF-8");
System.out.println("msgString =" + msgString);
assertTrue(msgString.startsWith(expected));
|