Methods Summary |
---|
public static void | main(java.lang.String[] argv)Method main
TestSOAPBody tester = new TestSOAPBody("TestSOAPBody");
tester.testSoapBodyBUG();
|
public static junit.framework.Test | suite()Method suite
return new TestSuite(test.message.TestSOAPBody.class);
|
public void | testSaveChanges()Method testSaveChanges
MimeHeaders mimeheaders = new MimeHeaders();
mimeheaders.addHeader("Content-Type", "text/xml");
ByteArrayInputStream instream = new ByteArrayInputStream(xmlString.getBytes());
MessageFactory factory =
MessageFactory.newInstance();
SOAPMessage msg =
factory.createMessage(mimeheaders, instream);
org.apache.axis.client.AxisClient axisengine =
new org.apache.axis.client.AxisClient();
((Message) msg).setMessageContext(
new org.apache.axis.MessageContext(axisengine));
SOAPPart sp = msg.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPBody sb = se.getBody();
Node myNode = (Element) sb.getElementsByTagName("City").item(0);
myNode.replaceChild( myNode.getOwnerDocument().createTextNode("NY"), myNode.getFirstChild());
msg.saveChanges();
sp = msg.getSOAPPart();
se = sp.getEnvelope();
sb = se.getBody();
myNode = (Element) sb.getElementsByTagName("City").item(0);
Node city = myNode.getFirstChild();
assertEquals("City name did not change to NY", city.toString(), "NY");
|
public void | testSoapBodyBUG()Method testSoapBodyBUG
MimeHeaders mimeheaders = new MimeHeaders();
mimeheaders.addHeader("Content-Type", "text/xml");
ByteArrayInputStream instream = new ByteArrayInputStream(xmlString.getBytes());
MessageFactory factory =
MessageFactory.newInstance();
SOAPMessage msg =
factory.createMessage(mimeheaders, instream);
org.apache.axis.client.AxisClient axisengine =
new org.apache.axis.client.AxisClient();
// need to set it not null , if not nullpointer in sp.getEnvelope()
((org.apache.axis.Message) msg).setMessageContext(
new org.apache.axis.MessageContext(axisengine));
SOAPPart sp = msg.getSOAPPart();
javax.xml.soap.SOAPEnvelope se = sp.getEnvelope();
javax.xml.soap.SOAPHeader sh = se.getHeader();
SOAPBody sb = se.getBody();
Iterator it = sb.getChildElements();
int count = 0;
while (it.hasNext()) {
SOAPBodyElement el = (SOAPBodyElement) it.next();
count++;
Name name = el.getElementName();
System.out.println("Element:" + el);
System.out.println("BODY ELEMENT NAME:" + name.getPrefix() + ":"
+ name.getLocalName() + " " + name.getURI());
}
assertTrue(count == 1);
|