Oracle Application Server Web Services開発者ガイド 10g(10.1.3.1.0) B31868-01 |
|
この付録では、WSDLバージョン1.1用Java APIのOracle実装(OraWSDL)について説明します。このAPIを使用することで、メモリー内のWSDLドキュメントを読取り、変更、書込み、作成および再編成することができます。
主要なWSDL用Java APIは、javax.wsdl.factory.WSDLFactory
クラスです。アプリケーションでは、この抽象クラスを使用することで、新しい定義、新しいWSDLReaders
および新しいWSDLWriters
を生成できるWSDLファクトリを取得できます。
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ファクトリ・インスタンスを作成しています。
... //--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コードを挿入します。
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 + "!"); } }
|
![]() Copyright © 2006 Oracle Corporation. All Rights Reserved. |
|