MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPBody soapBody = soapEnvelope.getBody();
String prefixoRemover = soapEnvelope.getPrefix();
boolean removeuPrefixo = soapEnvelope.removeNamespaceDeclaration(prefixoRemover);
if (removeuPrefixo) {
System.out.println("removeu o prefixo do Envelope"); // Passa por aqui com sucesso
}
soapEnvelope.addNamespaceDeclaration("soap", "http://schemas.xmlsoap.org/soap/envelope/");
soapEnvelope.setPrefix(prefix); // Exception aqui
[/code]
Exception:
[color=red]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 org.apache.axiom.om.impl.dom.NodeImpl.setPrefix(NodeImpl.java:127)
at br.com.ps.transp.util.ciot.Teste.createSOAPRequest(Teste.java:78)
at br.com.ps.transp.util.ciot.Teste.main(Teste.java:48)
[/color]
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
SOAPBody soapBody = soapEnvelope.getBody();
String prefixoRemover = soapEnvelope.getPrefix();
boolean removeuPrefixo = soapEnvelope.removeNamespaceDeclaration(prefixoRemover);
if (removeuPrefixo) {
System.out.println("removeu o prefixo do Envelope"); // Passa por aqui com sucesso
}
soapEnvelope.addNamespaceDeclaration("soap", "http://schemas.xmlsoap.org/soap/envelope/");
soapEnvelope.setPrefix(prefix); // Exception aqui
[/code]
Exception:
[color=red]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 org.apache.axiom.om.impl.dom.NodeImpl.setPrefix(NodeImpl.java:127)
at br.com.ps.transp.util.ciot.Teste.createSOAPRequest(Teste.java:78)
at br.com.ps.transp.util.ciot.Teste.main(Teste.java:48)
[/color][/quote]
A api diz…
Por que quer tornar seu webservice incompativel com a especificação XML?