How to add child node for SOAPBody?

java, soap

Solution

You need to add a namespace declaration:

envelope.addNamespaceDeclaration("ns3", "your-namespace");

Problem

I saw Working Soap client example . But when i add child node for soapbody it throw an exception. Here is error: Exception in thread "main" com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Unable to locate namespace for prefix ns3 Here is code for SOAPrequest: ``` MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody soapBody = envelope.getBody(); SOAPElement node1 = soapBody.addChildElement("lookupEligibility","ns3"); ``` How to solve it. Thanks!!!!

Original source

Related problems