ヘッダーをスキップ

Oracle Application Server Web Services開発者ガイド
10g(10.1.3.1.0)

B31868-01
目次
目次
索引
索引

戻る 次へ

B WSDL 1.1 APIのOracle実装

この付録では、WSDLバージョン1.1用Java APIのOracle実装(OraWSDL)について説明します。このAPIを使用することで、メモリー内のWSDLドキュメントを読取り、変更、書込み、作成および再編成することができます。

主要なWSDL用Java APIは、javax.wsdl.factory.WSDLFactoryクラスです。アプリケーションでは、この抽象クラスを使用することで、新しい定義、新しいWSDLReadersおよび新しいWSDLWritersを生成できるWSDLファクトリを取得できます。

関連資料

次のWebサイトにあるWSDLバージョン1.1用Java APIの説明。

http://www.jcp.org/en/jsr/detail?id=110 

OraWSDL APIの概要

javax.wsdl.factory.WSDLFactoryクラスのOracleAS Web Services実装は、oracle.webservices.wsdl.WSDLFactoryImplです。このクラスを使用して、新しいWSDLファクトリ・インスタンスを作成します。OracleAS Web Servicesには、抽象WSDLFactoryクラスに必要となるXMLSchema、SOAP、HTTPおよびMIMEをサポートする拡張機能が用意されています。

WSDL_READ_TIMEOUTプロパティは、HTTPプロトコルまたはHTTPSプロトコルでのみ使用できます。このプロパティには、リモートWSDL定義についてのリクエストに対するレスポンスを受信するまでにWSDLReader実装が待機する最大時間を秒単位で指定します。

次に、WSDLFactoryクラスに用意されている機能を使用した例をいくつか示します。

例B-1に、WSDL用Java APIを使用してWSDLファイルを取得および操作するサンプル・コードを示します。サンプルでは次のタスクの例が示されています。

WSDLファクトリを取得するコード行では、WSDLFactory.newInstanceメソッドでOracle WSDLFactoryImplクラスを使用し、WSDLファクトリ・インスタンスを作成しています。

例B-1    WSDL用Java APIを使用してWSDLを操作する方法

   ...
//--Get the WSDLFactory. You must specifiy Oracle's implementation class name
       WSDLFactory wsdlFactory = 
WSDLFactory.newInstance("oracle.webservices.wsdl.WSDLFactoryImpl");
   ...
//--Create a reader and register the standard extensions
       WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
       ExtensionRegistry extensionRegistry = 
wsdlFactory.newPopulatedExtensionRegistry();
       wsdlReader.setExtensionRegistry(extensionRegistry);
   ...
 //--Set a sixty-second timeout for reading the WSDL definition
        System.setProperty(oracle.webservices.wsdl.WSDLFactoryImpl.WSDL_READ_TIMEOUT, 
"60" ); 
   ...
//--Read a WSDL file, including any imports
       Definition def = wsdlReader.readWSDL("http://some.com/someservice?WSDL");
   ...
//--You can now explore the WSDL definition, for example,
       Map services = def.getServices();
       String targetNamespace = def.getTargetNamespace();
   ...

例B-2のコードで、javax.xml.rpc.server.ServletEndpointContextおよびjavax.servlet.ServletContextクラスにあるメソッドを使用してWSDLを取得する方法を示します。取得されたWSDLは、InputStreamに格納されます。この技法は、WSDLに対してのみでなく、どのようなリソースに対しても使用できます。

// code to handle the input streamセクションには、例B-1のサンプル内にあるような、WSDLファイルを取得および操作するためのOraWSDL APIコードを挿入します。

例B-2    リソースとしてのWSDLの取得

public class HelloImpl  implements javax.xml.rpc.server.ServiceLifecycle {
    // default constructor
    public HelloImpl() {
}
    public init(Object context){
        javax.xml.rpc.server.ServletEndpointContext ctx = (javax.xml.rpc.server.ServletEndpointContext) context;
        javax.servlet.ServletContext servletContext= ctx.getServletContext(); 
        //we can read any other resource the same way.
        java.io.InputStream wsdlDocument = servletContext.getResourceAsStream("/WEB-INF/wsdl/MyWsdl.wsdl")) ;

       // code to handle the input stream
      ...
    }
 
   //empty implementation
    public void destroy() {}

    // sayHello method
    public String sayHello(String name) {
        return ("Hello " + name + "!");
    }
} 

戻る 次へ
Oracle
Copyright © 2006 Oracle Corporation.

All Rights Reserved.
目次
目次
索引
索引