###前提・実現したいこと
Javaでsoap通信するための送信メッセージを作成していますが、下記のように、ふたつの目の[xmlns:xsd="http://www.w3.org/2001/XMLSchema"]をひとつのタグの中に付ける実装方法がわかりません。
SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
SOAP-ENV:Header/
SOAP-ENV:Body
<SOAP xmlns="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
</SOAP> </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
###発生している問題・エラーメッセージ
body.addBodyElement(envelope.createName("ErcSoap", "xsi", "http://www.w3.org/2001/XMLSchema-instance"));
このように書けば一つ目のURIは書けるのはわかるのですが、そのあと続けて、"xmlns:xsd="http://www.w3.org/2001/XMLSchema"も付与する方法をご教授下さい。
###該当のソースコード
import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPConnection; import javax.xml.soap.SOAPConnectionFactory; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; public class SOAPTip { public static void main(String args[]) { try { // SOAP 接続の作成 SOAPConnectionFactory soapConnFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnFactory.createConnection(); // SOAP メッセージ・オブジェクトの作成 MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); // Create objects for the message parts SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); // 本体への情報の取り込み body.addBodyElement(envelope.createName("ErcSoap", "xsi", "http://www.w3.org/2001/XMLSchema-instance")); //Save the message message.saveChanges(); //Check the input System.out.println("\nREQUEST:\n"); message.writeTo(System.out); System.out.println(); //Send the message and get a reply //Set the destination String destination = "http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //Send the message SOAPMessage reply = connection.call(message, destination); //Check the output System.out.println("\nRESPONSE:\n"); //Create the transformer TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); //Extract the content of the reply Source sourceContent = reply.getSOAPPart().getContent(); //Set the output for the transformation StreamResult result = new StreamResult(System.out); transformer.transform(sourceContent, result); System.out.println(); //Close the connection connection.close(); } catch(Exception e) { System.out.println(e.getMessage()); } }
###試したこと
SOAPEnvelope.createNameメソッドにふたつ以上のURIが渡せるか調査しましたが見つかりませんでした。
###補足情報(言語/FW/ツール等のバージョンなど)
Java 1.8
あなたの回答
tips
プレビュー