WebSphere Application Server は、Java API for XML-based RPC (JAX-RPC) に対する拡張を提供し、REQUEST_SOAP_HEADERS および RESPONSE_SOAP_HEADERS スタブ・プロパティーを含む、Java 2 Platform, Enterprise Edition (J2EE) クライアント・プログラミング・モデルを提供します。 これら 2 つのプロパティーの使用例を以下に示します。
以下のプログラミング例では、Web サービスの要求および応答内で、2 つの要求 SOAP ヘッダーを送信し、1 つの応答 SOAP ヘッダーを受け取る方法を示します。
1 //Create the request and response hashmaps. 2 HashMap requestHeaders=new HashMap(); 3 HashMap responseHeaders=new HashMap(); 4 5 //Add "AtmUuid1" and "AtmUuid2" to the request hashmap. 6 requestHeaders.put(new QName("com.rotbank.security", "AtmUuid1"), 7 "<AtmUuid1 xmlns=¥"><uuid>ROTB-0A01254385FCA09</uuid></AtmUuid1>"); 8 requestHeaders.put(new QName("com.rotbank.security", "AtmUuid2"), 9 ((IBMSOAPFactory)SOAPFactory.newInstance()).createElementFromXMLString( 10 "x:AtmUuid2 xmlns:x=¥"com.rotbank.security¥"><x:uuid>ROTB-0A01254385FCA09 </x:uuid><x:AtmUuid2>")); 11 12 //Add "ServerUuid" to the response hashmap. 13 //If "responseHeaders" is empty, all the SOAP headers are 14 //extracted from the response message. 15 responseHeaders.put(new QName("com.rotbank.security","ServerUuid"), null); 1617 //Set the properties on the Stub object. 18 stub.setProperty(Constants.REQUEST_SOAP_HEADERS.requestHeaders); 19 stub.setProperty(Constants.RESPONSE_SOAP_HEADERS.responseHeaders); 20 21 //Call the operationon the Stub. 22 stub.foo(parm2, parm2); 23 24 //Retrieve "ServerUuid" from the response hashmap. 25 SOAPElement serverUuid = 26 (SOAPElement) responseHeaders.get(new QName("com.rotbank.security","ServerUuid")); 2728 //Note: "serverUuid" now equals a SOAPElement object that represents the 29 //following code: 30//"<y:ServerUuid xmlns:y=¥"com.rotbank.security¥"><:uuid>ROTB-0A03519322FSA01 </y:uuid></y:ServerUuid.");
行 2 から 3 では、要求および応答 SOAP ヘッダーで使用される新しい HashMap が作成されます。
行 6 から 10 では、AtmUuid1 および AtmUuid2 ヘッダー・エレメントが要求 HashMap に追加されます。
行 15 では、ServerUuid ヘッダー・エレメント名が、ヌル値と共に応答 HashMap に追加されます。
行 18 では、要求 HashMap がスタブ・オブジェクト上のプロパティーとして設定されます。 これにより、AtmUuid1 および AtmUuid2 ヘッダーが、スタブ・オブジェクト上で呼び出されたオペレーションに関連付けられた各要求メッセージに追加されます。
行 19 では、応答 HashMap がスタブ・オブジェクト上のプロパティーとして設定されます。 これにより、ServerUuid ヘッダーが、スタブ・オブジェクト上で呼び出されたオペレーションに関連付けられた各応答メッセージから抽出されます。
行 22 では、Web サービス・オペレーションがスタブ・オブジェクト上で呼び出されています。
行 25 から 26 では、ServerUuid ヘッダーが応答 HashMap から取得されています。 このヘッダーは、Web サービス・エンジンにより、応答メッセージから抽出され、HashMap に挿入されます。
API および SPI で使用される文書については、参照: 生成 API 資料を参照してください。 API および SPI インターフェースについて説明するこのトピックの指示に従います。
Web サービスの開発で使用される標準および API については、仕様を参照してください。