这两条肥皂信息有效吗?不同的部分是命名空间属性 xmlns="http://www.sigvalue.com/acc"。第一个soap是一个示例,第二个由java代码生成以制作相同的soap消息。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetNGPList xmlns="http://www.sigvalue.com/acc">
<UserData>
<senderId>string</senderId>
<channelId>string</channelId>
<timeStamp>dateTime</timeStamp>
</UserData>
<zipCode>string</zipCode>
</GetNGPList>
</soap:Body>
</soap:Envelope>
.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetNGPList>
<UserData xmlns="http://www.sigvalue.com/acc">
<senderId>string</senderId>
<channelId>string</channelId>
<timeStamp>dateTime</timeStamp>
</UserData xmlns="http://www.sigvalue.com/acc">
<zipCode>string</zipCode>
</GetNGPList>
</soap:Body>
</soap:Envelope>
如果第二个肥皂无效,我怎样才能使它与第一个相同?GetNGPList.addNamespaceDeclaration("xmlns"," http://www.sigvalue.com/acc "); 这条线没有按预期工作。这是JAVA代码:
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
// SOAP Envelope
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("xsi", gXSIServerURI);
envelope.addNamespaceDeclaration("xsd", gXSDServerURI);
// SOAP Body
SOAPBody soapBody = envelope.getBody();
SOAPElement GetNGPList = soapBody.addChildElement("GetNGPList");
GetNGPList.addNamespaceDeclaration("xmlns","http://www.sigvalue.com/acc");
SOAPElement UserData = GetNGPList.addChildElement("UserData");
SOAPElement senderId = UserData.addChildElement("senderId");
SOAPElement channelId = UserData.addChildElement("channelId");
SOAPElement timeStamp = UserData.addChildElement("timeStamp");
senderId.addTextNode("string");
channelId.addTextNode("string");
timeStamp.addTextNode("dateTime");
SOAPElement zipCode = GetNGPList.addChildElement("zipCode");
zipCode.addTextNode("string");
MimeHeaders headers = soapMessage.getMimeHeaders();
headers.addHeader("SOAPAction", "sample");
soapMessage.saveChanges();
/* Print the request message */
//System.out.print("Request SOAP Message = ");
soapMessage.writeTo(System.out);