これら 2 つの SOAP メッセージは有効ですか? 異なる部分は、名前空間属性 xmlns="http://www.sigvalue.com/acc" です。最初の SOAP はサンプルで、2 番目は同じ SOAP メッセージを作成するために Java コードによって生成されたものです。
<?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>
2 番目の石鹸が無効な場合、どうすれば最初の石鹸と同じにできますか? 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);