Converting a soap message to a document using wssj
- by ellander
I have been supplied with a jar file that should enable me to connect to a 3rd party system. When I run the necessary class I get an error which states that the namespace for the prefix "SOAPENV" has not been declared. Using jad I have decompiled the class files to try suss out what is going on and the error seems to occur when a soap message is being converted to a document. Unfortunately I don't know much about wssj. Can anyone suggest what the problem might be? I'm wondering if it's an incompatibility issue as it's not a recently created jar file and the decompiled code looks different to all the examples I can find. For example, in this section the examples have addNamesSpaceDeclaration rather than addAttribute...
MessageFactory factory = MessageFactory.newInstance();
SOAPFactory sf = SOAPFactory.newInstance();
SOAPMessage msg = factory.createMessage();
MimeHeaders headers = msg.getMimeHeaders();
headers.addHeader("Content-Type", "text/xml");
SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
env.addAttribute(sf.createName("xmlns:xsi"), "http://www.w3.org/2001/XMLSchema-instance");