S
Son KwonNam
I have the following java SAAJ source code.
----------------------------------------------------------------------
import javax.xml.soap.*;
public class SoapBodyTest {
/// Field
/// Constructor
/// Method
public static void main(String args[]) throws Exception {
//SOAPMessage
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage requestMessage = messageFactory.createMessage();
//SOAPPart
SOAPPart soapPart = requestMessage.getSOAPPart();
//SOAPEnvelope
SOAPEnvelope envelope = soapPart.getEnvelope();
//SOAPFactory
SOAPFactory soapFactory = SOAPFactory.newInstance();
//SOAPBody
SOAPBody body = envelope.getBody();
//Body Entry
Name bodyName = soapFactory.createName("sayHello", "ns0", null);
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
// Body Entry's children
Name childName = soapFactory.createName("String_1");
SOAPElement childElement = bodyElement.addChildElement(childName);
Name typeName = soapFactory.createName("xsi:type");
childElement.addAttribute(typeName, "xsd:string"); // ## LINE 30 ##
childElement.addTextNode("mincheol");
//SOAPConnection
SOAPConnectionFactory soapConnectionFactory =
SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
// send message
SOAPMessage responseMessage = connection.call(requestMessage,
"http://localhost:9000/hello/webservice");
}
}
----------------------------------------------------------------------
This program works nicely with JWSDP 1.1's jar libraries.
But with JWSDP 1.5's jar libraries, This program does not work and shows
the following Exception.
----------------------------------------------------------------------
Exception in thread "main" org.w3c.dom.DOMException: NAMESPACE_ERR: An
attempt is made to create or change an object in a way which is
incorrect with regard to namespaces.
at
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkDOMNSErr(CoreDocumentImpl.java:2327)
at
com.sun.org.apache.xerces.internal.dom.AttrNSImpl.setName(AttrNSImpl.java:151)
at
com.sun.org.apache.xerces.internal.dom.AttrNSImpl.<init>(AttrNSImpl.java:112)
at
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttributeNS(CoreDocumentImpl.java:1959)
at
com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl.createAttributeNS(SOAPDocumentImpl.java:142)
at
com.sun.org.apache.xerces.internal.dom.ElementImpl.setAttributeNS(ElementImpl.java:680)
at
com.sun.xml.messaging.saaj.soap.impl.ElementImpl.addAttributeBare(ElementImpl.java:298)
at
com.sun.xml.messaging.saaj.soap.impl.ElementImpl.addAttribute(ElementImpl.java:282)
at SoapBodyTest.main(SoapBodyTest.java:30)
----------------------------------------------------------------------
How to get this program work with JWSDP 1.5??
Thank you in advance.
KwonNam.
----------------------------------------------------------------------
import javax.xml.soap.*;
public class SoapBodyTest {
/// Field
/// Constructor
/// Method
public static void main(String args[]) throws Exception {
//SOAPMessage
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage requestMessage = messageFactory.createMessage();
//SOAPPart
SOAPPart soapPart = requestMessage.getSOAPPart();
//SOAPEnvelope
SOAPEnvelope envelope = soapPart.getEnvelope();
//SOAPFactory
SOAPFactory soapFactory = SOAPFactory.newInstance();
//SOAPBody
SOAPBody body = envelope.getBody();
//Body Entry
Name bodyName = soapFactory.createName("sayHello", "ns0", null);
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
// Body Entry's children
Name childName = soapFactory.createName("String_1");
SOAPElement childElement = bodyElement.addChildElement(childName);
Name typeName = soapFactory.createName("xsi:type");
childElement.addAttribute(typeName, "xsd:string"); // ## LINE 30 ##
childElement.addTextNode("mincheol");
//SOAPConnection
SOAPConnectionFactory soapConnectionFactory =
SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
// send message
SOAPMessage responseMessage = connection.call(requestMessage,
"http://localhost:9000/hello/webservice");
}
}
----------------------------------------------------------------------
This program works nicely with JWSDP 1.1's jar libraries.
But with JWSDP 1.5's jar libraries, This program does not work and shows
the following Exception.
----------------------------------------------------------------------
Exception in thread "main" org.w3c.dom.DOMException: NAMESPACE_ERR: An
attempt is made to create or change an object in a way which is
incorrect with regard to namespaces.
at
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkDOMNSErr(CoreDocumentImpl.java:2327)
at
com.sun.org.apache.xerces.internal.dom.AttrNSImpl.setName(AttrNSImpl.java:151)
at
com.sun.org.apache.xerces.internal.dom.AttrNSImpl.<init>(AttrNSImpl.java:112)
at
com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttributeNS(CoreDocumentImpl.java:1959)
at
com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl.createAttributeNS(SOAPDocumentImpl.java:142)
at
com.sun.org.apache.xerces.internal.dom.ElementImpl.setAttributeNS(ElementImpl.java:680)
at
com.sun.xml.messaging.saaj.soap.impl.ElementImpl.addAttributeBare(ElementImpl.java:298)
at
com.sun.xml.messaging.saaj.soap.impl.ElementImpl.addAttribute(ElementImpl.java:282)
at SoapBodyTest.main(SoapBodyTest.java:30)
----------------------------------------------------------------------
How to get this program work with JWSDP 1.5??
Thank you in advance.
KwonNam.