我看到了Working Soap client example。但是当我为soapbody添加子节点时,它会引发异常。
这是错误:
线程“main”中的异常com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:无法找到前缀ns3的命名空间
以下是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");
如何解决它。感谢!!!!
答案 0 :(得分:5)
您需要添加名称空间声明:
envelope.addNamespaceDeclaration("ns3", "your-namespace");