Oracle Service RegistryのWSDL2UDDIデモ・セットは、Oracle Service RegistryのWSDL2UDDI Application Programming Interface(API)の機能およびこのAPIの使用方法のデモンストレーションを行うために使用します。 このOracle Service Registry WSDL2UDDIデモでは、UDDI Version 2.0.4 Specificationを扱います。WSDLを問い合せて、SOAPインタフェース経由でUDDIレジストリに公開する方法を学習します。 Oracle Service RegistryのWSDL2UDDIデモ・セットには、WSDL2UDDIクライアントAPIの学習を支援する次のデモが含まれています。
PublishWSDL Publish_wsdlオブジェクトをビルドして入力し、UDDIレジストリのWSDL2UDDIスタブを取得し、authTokenを取得し、publish_wsdlコールを実行する方法のデモンストレーションです。
UnPublishWSDL Unpublish_wsdlオブジェクトをビルドして入力し、UDDIレジストリのWSDL2UDDIスタブを取得し、authTokenを取得し、unpublish_wsdlコールを実行する方法のデモンストレーションです。
FindWSDL Find_wsdlServiceInfoオブジェクトをビルドして入力し、UDDIレジストリのWSDL2UDDIスタブを取得し、authTokenを取得し、find_wsdlServiceInfoコールを実行する方法のデモンストレーションです。
GetWSDL Get_wsdlServiceInfoオブジェクトをビルドして入力し、UDDIレジストリのWSDL2UDDIスタブを取得し、authTokenを取得し、get_wsdlServiceInfoコールを実行する方法のデモンストレーションです。
Oracle Service Registryがすでにインストールされ、環境変数REGISTRY_HOMEにレジストリのインストール場所が設定されていることを想定しています。
Oracle Service Registryのデモを実行するには、レジストリが実行中である必要があります。
デモを構成する必要があります。構成システムには、グローバルとローカルの2つのレベルがあります。グローバル・レベルで定義されたプロパティは、ローカル・レベルで上書きできます。グローバル・プロパティは、次のファイルにあります。
Windows: | %REGISTRY_HOME%¥demos¥env.properties |
UNIX: | $REGISTRY_HOME/demos/env.properties |
Oracle Service Registryのインストール中に設定された値はそのまま使用でき、値の変更はすべてのデモに影響を与えます。単一のデモについて(つまりローカル・レベルで)一部のプロパティの値を再定義する必要がある場合は、env.propertiesを編集してください。このファイルは、ファイルrun.sh(run.bat)と同じディレクトリにあります。WSDL2UDDIデモのローカル・レベルのプロパティは、次のファイルからロードされます。
Windows: | %REGISTRY_HOME%¥demos¥basic¥wsdl¥v2¥env.properties |
UNIX: | $REGISTRY_HOME/demos/basic/wsdl/v2/env.properties |
表16 デモで使用されるプロパティ
名前 | デフォルト値 | 説明 |
---|---|---|
uddi.demos.user.john.name | demo_john | 1人目のユーザーの名前 |
uddi.demos.user.john.password | demo_john | 1人目のユーザーのパスワード |
uddi.demos.url.wsdl2uddi | http://localhost:8888/registry/uddi/wsdl2uddi | wsdl2uddi Webサービス・ポートのURL |
uddi.demos.url.security | http://localhost:8888/registry/uddi/security | セキュリティWebサービス・ポートのURL |
この項では、すべてのデモで使用されるプログラミング・パターンを、PublishWSDLデモを例にして説明します。ソース・コードは次のファイルにあります。
Windows: | %REGISTRY_HOME%¥demos¥basic¥wsdl2uddi¥src¥demo¥uddi¥v2¥wsdl2uddi¥PublishWSDL.java |
UNIX: | $REGISTRY_HOME/demos/basic/wsdl2uddi/src/demo/uddi/v2/wsdl2uddi/PublishWSDL.java |
mainメソッドは非常に単純です。ユーザーの入力を収集した後、Securityスタブを取得してユーザーを認可します。結果として得られるauthInfo文字列は、Publishリクエストに渡される秘密鍵です。Publishリクエストは、createPublish()メソッドで作成され、初期化されます。
ユーザーによるWSDLの選択は、publishWSDL()メソッド内で、選択されたbusinessEntityに公開されます。
正常に処理されると、UDDIレジストリからWsdlDetailオブジェクトが返されて出力されます。
最後の手順で、authInfo文字列を廃棄します。これにより、悪質なユーザーがこの文字列を利用して他のユーザーのアカウントの安全性を損なうことができなくなります。
String businessKey = UserInput.readString("Enter businessKey", "d7222f66-08aa-3a6e-a299-2ed4ac785682"); String url = UserInput.readString("Enter WSDL URL", "http://localhost:8888/registry/uddi/doc/demos/EmployeeList.wsdl"); System.out.println(); UDDI_Security_PortType security = getSecurityStub(); String authInfo = getAuthInfo(user, password, security); Publish_wsdl publish = createPublish(businessKey, url, authInfo); WsdlDetail result = publishWSDL(publish); printWsdlDetail(result); discardAuthInfo(authInfo, security);
ヘルパー・メソッドgetSecurityStub()によって、URL_SECURITYプロパティで指定されたURLでリスニングするWebサービスのUDDI Securityスタブが返ります。
public static UDDI_Security_PortType getSecurityStub() throws SOAPException { // you can specify your own URL in property - uddi.demos.url.security String url = DemoProperties.getProperty(URL_SECURITY, "http://localhost:8888/registry/uddi/security"); System.out.print("Using Security at url " + url + " .."); UDDI_Security_PortType security = UDDISecurityStub.getInstance(url); System.out.println(" done"); return security; }
同様に、ヘルパー・メソッドgetWsdl2uddiStub()によって、URL_WSDL2UDDIプロパティで指定されるURLでリスニングするWebサービスのWSDL2UDDIスタブが返ります。
public static Wsdl2uddiApi getWsdl2uddiStub() throws SOAPException { // you can specify your own URL in property - uddi.demos.url.wsdl2uddi String url = DemoProperties.getProperty(URL_WSDL2UDDI, "http://localhost:8888/registry/uddi/wsdl2uddi"); System.out.print("Using WSDL2UDDI at url " + url + " .."); Wsdl2uddiApi inquiry = Wsdl2uddiStub.getInstance(url); System.out.println(" done"); return inquiry; }
getAuthInfo()メソッドを使用して、ユーザーをUDDIレジストリに対して認可し、秘密鍵authInfoを取得します。
public static String getAuthInfo(String userName, String password, UDDI_Security_PortType security) throws InvalidParameterException, UDDIException { System.out.print("Logging in .."); AuthToken authToken = security.get_authToken(new Get_authToken(userName, password)); System.out.println(" done"); return authToken.getAuthInfo(); }
discardAuthInfo()メソッドによって、秘密鍵authInfoが無効化され、再利用できなくなります。
public static DispositionReport discardAuthInfo(String authInfo, UDDI_Security_PortType security) throws InvalidParameterException, UDDIException { System.out.print("Logging out .."); DispositionReport dispositionReport = security.discard_authToken(new Discard_authToken(authInfo)); System.out.println(" done"); return dispositionReport; }
createPublish()メソッドを使用して、Publishクラスの新規インスタンスを作成し、各パラメータからの値で初期化します。
public static Publish_wsdl createPublish(String businessKey, String url, String authInfo) throws InvalidParameterException { System.out.println("businessKey = " + businessKey); System.out.println("url = " + url); WsdlMapping wsdlMapping = new WsdlMapping(); wsdlMapping.setBusinessKey(businessKey); Wsdl wsdl = new Wsdl(url); WsdlDetail wsdlDetail = new WsdlDetail(wsdl, wsdlMapping); Publish_wsdl publish = new Publish_wsdl(wsdlDetail, authInfo); return publish; }
WSDL2UDDI APIコールPublish_wsdlが、publishWSDL()メソッドで次のように実行されます。
public static WsdlDetail publishWSDL(Publish_wsdl save) throws UDDIException, SOAPException { Wsdl2uddiApi publishing = getWsdl2uddiStub(); System.out.print("Save in progress ..."); WsdlDetail wsdlDetail = publishing.publish_wsdl(save); System.out.println(" done"); return wsdlDetail; }
返されたWsdlDetailは、printWsdlDetail()メソッドによって表示されます。
Oracle Service RegistryのクライアントAPIで重要な点は、それぞれのUDDIオブジェクトにメソッドtoXML()が含まれ、それによってそのXML表現が、判読可能な書式化されたリストで返されることです。
public static void printWsdlDetail(WsdlDetail wsdlDetail) { System.out.println(); System.out.println(wsdlDetail.toXML()); }
この項では、Oracle Service RegistryのBasicのPublishingデモ・セットをビルドして実行する方法を示します。 引き続きPublishWSDLデモを使用します。
デモが適切に構成され、Oracle Service Registryが実行中であることを確認してください。
次のディレクトリに移動します。
Windows | %REGISTRY_HOME%¥demos¥basic¥wsdl¥v2 |
UNIX | $REGISTRY_HOME/demos/basic/wsdl/v2 |
次のコマンドを使用して、すべてのデモをビルドします。
Windows: | run.bat make |
UNIX: | ./run.sh make |
![]() | 注意 |
---|---|
Windowsプラットフォームでデモをコンパイルすると、次のテキストが表示されることがあります。 A subdirectory or file ..\..\common\.\build\classes already exists. これは予想される現象であり、問題を示すものではありません。 |
利用可能なすべてのデモのリストを表示するには、次のコマンドを実行します。
Windows: | run.bat help |
UNIX: | ./run.sh help |
選択したデモは、runコマンドのパラメータにデモの名前を指定して実行できます。 たとえば、PublishWSDLデモを実行するには、次のように起動します。
Windows: | run.bat PublishWSDL |
UNIX: | ./run.sh PublishWSDL |
このデモの出力は次のようになります。
Running PublishWSDL demo... Enter businessKey [d7222f66-08aa-3a6e-a299-2ed4ac785682]: Enter WSDL URL [http://localhost:8888/registry/uddi/inquiry/wsdl]: http://localhost:8888/registry/uddi/doc/demos/EmployeeList.wsdl Using Publishing at url https://mycomp.com:8443/registry/uddi/publishing .. done Logging in .. done businessKey = d7222f66-08aa-3a6e-a299-2ed4ac785682 url = http://localhost:8888/registry/uddi/doc/demos/EmployeeList.wsdl Using WSDL2UDDI at url https://mycomp.com:8443/registry/uddi/wsdl2uddi .. done Save in progress ... done <wsdlDetail xmlns="http://systinet.com/uddi/wsdl2uddi/v2/5.0"> <wsdl> <wsdlLocation>http://localhost:8888/registry/uddi/doc/demos/EmployeeList.wsdl</wsdlLocation> </wsdl> <wsdlMapping> <businessKey xmlns="urn:uddi-org:api_v2">d7222f66-08aa-3a6e-a299-2ed4ac785682< /businessKey> <services> <service name="EmployeeList" namespace=" http://systinet.com/wsdl/demo/uddi/services/" publishingMethod="rewrite"> <serviceKey xmlns="urn:uddi-org:api_v2"> d0a50390-af1c-11d8-b9bf-eb2d7e20b9bf</serviceKey> <ports> <port name="EmployeeList" publishingMethod="rewrite"> <bindingKey xmlns="urn:uddi-org:api_v2"> d0aca4b0-af1c-11d8-b9bf-eb2d7e20b9bf</bindingKey> </port> </ports> </service> </services> <bindings> <binding name="EmployeeList_binding" namespace="http://systinet.com/wsdl/demo/uddi/services/" publishingMethod="rewrite"> <tModelKey xmlns="urn:uddi-org:api_v2"> uuid:d07da570-af1c-11d8-b9bf-eb2d7e20b9bf</tModelKey> </binding> </bindings> <portTypes> <portType name="EmployeeList_portType" namespace="http://systinet.com/wsdl/demo/uddi/services/" publishingMethod="rewrite"> <tModelKey xmlns="urn:uddi-org:api_v2"> uuid:d0658990-af1c-11d8-b9bf-eb2d7e20b9bf</tModelKey> </portType> </portTypes> </wsdlMapping> </wsdlDetail> Logging out .. done
デモを再ビルドするには、run.bat clean(./run.sh clean)を実行してclassesディレクトリを削除し、run.bat make(./run.sh make)を実行してデモ・クラスを再ビルドします。