機械翻訳について

Oracle Database

APEX_WEB_SERVICE、UTL_HTTPパッケージ、Application Express (Apex)などのOracle Databaseの様々な機能を使用して、SOAP Webサービスを呼び出します。

APEX Webサービス

Application Express (APEX)スキーマを使用してデータベース上のWebサービスを呼び出すには、APEX_WEB_SERVICEを使用します。

次に示すサンプル・クライアント・コードでは、次のことが実行されます。
  1. サービスを呼び出すxmlペイロードを作成します。 このコード例は、ハードコードされた文字列を要求に渡します。

  2. UTL_HTTPパッケージを使用するAPEX_WEB_SERVICE APIを使用してサービスを呼び出します。

  3. 応答を受信して処理します。 このコード例は、応答を単に出力します。

declare
	l_result XMLTYPE;
	l_envelope CLOB;
BEGIN
	-- Construct xml payload to invoke the service. In this example, it is a hard coded string.
	l_envelope := '<?xml version="1.0" encoding="UTF-8"?>
	<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
		xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
	<findRule
	xmlns="http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/ty
		   pes/">
	<findCriteria>
	  <fetchStart xmlns="http://xmlns.oracle.com/adf/svc/types/">0</fetchStart>
	  <fetchSize xmlns="http://xmlns.oracle.com/adf/svc/types/">-1</fetchSize>
	  <filter xmlns="http://xmlns.oracle.com/adf/svc/types/">
	    <group>
		  <upperCaseCompare>false</upperCaseCompare>
			<item>
			  <upperCaseCompare>false</upperCaseCompare>
			  <attribute>RuleId</attribute>
			  <operator>=</operator>
			  <value>300000000851162</value>
			</item>
		</group>
	  </filter>
	  <excludeAttribute xmlns="http://xmlns.oracle.com/adf/svc/types/">false</excludeAttribute>
	</findCriteria>
	<findControl>
	  <retrieveAllTranslations
		xmlns="http://xmlns.oracle.com/adf/svc/types/">false</retrieveAllTranslations>
	</findControl>
	</findRule>
	</soap:Body>
	</soap:Envelope>';
	-- Call the web service
	l_result := apex_web_service.make_request(
	p_url => 'https://host:port/icCnSetupCreditRulesPublicService/CreditRuleService?wsdl',
	p_action => 'http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/findRule',
	p_envelope => l_envelope,
	p_username => 'username',
	p_password => 'password' );
	dbms_output.put_line(l_result.getClobVal());
END;

UTL_HTTPパッケージ

XMLペイロードを作成および処理することで、HTTPS経由でUTL_HTTPパッケージを使用してSOAP Webサービスを呼び出します。 UTL_HTTPパッケージを使用する前に、次を構成します。
  • データベース・ネットワークへのアクセス

  • 証明書を含むWalletの作成(SSL経由でWebサービスにアクセスする場合)

詳細は、Oracle Help Centerで入手可能なFusion Middleware管理者ガイドを参照してください。 次に示すサンプル・クライアント・コードでは、次のことが実行されます。
  1. サービスを呼び出すxmlペイロードを作成します。 このコード例は、ハードコードされた文字列を要求に渡します。

  2. 要求に使用されるOracle Walletを設定します。 このWalletには、サービスをホストするサーバーの証明書が含まれている必要があり、HTTPSを使用してサービスにアクセスするために使用されます。

  3. POSTメソッドの新しいHTTP要求を作成します。

  4. 認証情報を使用してサービスを呼び出す要求を構成します。

  5. 要求のコンテンツ・タイプをxmlに、HTTPメソッドをPOSTに構成し、コンテンツの長さを設定します。

  6. 呼び出すSOAPActionを設定します。 呼出しはこの値がなくても行えますが、これが推奨される標準です。

  7. xmlペイロードを要求として接続に書き込みます。

  8. 応答を受信して処理します。 このコード例は、単に応答を出力します。

DECLARE
  -- Construct xml payload to invoke the service. In this example, it is a hard coded string.
  l_envelope VARCHAR2(32767) := '<soap:Envelope
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
			
			xmlns:xsd="http://www.w3.org/2001/XMLSchema">
		<soap:Body>
		<findRule
xmlns="http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/ty
pes/">
			<findCriteria>
			  <fetchStart
xmlns="http://xmlns.oracle.com/adf/svc/types/">0</fetchStart>
				<fetchSize xmlns="http://xmlns.oracle.com/adf/svc/types/">-
				1</fetchSize>
			<filter xmlns="http://xmlns.oracle.com/adf/svc/types/">
			  <group>
				<upperCaseCompare>false</upperCaseCompare>
				  <item>
					<upperCaseCompare>false</upperCaseCompare>
					<attribute>RuleId</attribute>
					<operator>=</operator>
					<value>300000000851162</value>
				  </item>
			  </group>
			</filter>
			<excludeAttribute
xmlns="http://xmlns.oracle.com/adf/svc/types/">false</excludeAttribute>
			</findCriteria>
			<findControl>
			  <retrieveAllTranslations
xmlns="http://xmlns.oracle.com/adf/svc/types/">false</retrieveAllTranslations>
			</findControl>
		</findRule>
		</soap:Body>
		</soap:Envelope>';
l_result VARCHAR2(32767) := null;
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_counter PLS_INTEGER;
l_length PLS_INTEGER;
BEGIN
  -- Sets the Oracle wallet used for request; required for HTTPS
  UTL_HTTP.set_wallet('file:/scratch/oradba/wallet', 'password');
  
  -- Creates a new HTTP request
  l_http_request :=
  UTL_HTTP.begin_request('https://host:port/icCnSetupCreditRulesPublicService/CreditRuleService',
  'POST','HTTP/1.1');
  
  -- Configure the authentication details 
  UTL_HTTP.SET_AUTHENTICATION(l_http_request, 'username', 'password');
  
  -- Configure the request content type to be xml and set the content length
  UTL_HTTP.set_header(l_http_request, 'Content-Type', 'text/xml');
  UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(l_envelope));
  
  -- Set the SOAP action to be invoked; while the call works without this, the value is expected to be set based on
  standards
  UTL_HTTP.set_header(l_http_request, 'SOAPAction',
  'http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/findRule');
  -- Write the xml payload to the request
  UTL_HTTP.write_text(l_http_request, l_envelope);
  
  -- Get the response and process it. In this example, we simply print out the response
  l_http_response := UTL_HTTP.get_response(l_http_request);
  UTL_HTTP.read_text(l_http_response, l_result);
  UTL_HTTP.end_response(l_http_response);
  l_counter := 1;
  l_length := LENGTH(l_result);
  WHILE (l_counter <= l_length) LOOP
    DBMS_OUTPUT.put_line(SUBSTR(l_result, l_counter, 80));
    l_counter := l_counter + 80;
  END LOOP;
END;
/

Oracle Application Express (Apex)

Webサービス参照オブジェクトを使用してWebサービスを統合するには、Apexを使用します。 これらのオブジェクトは、Webサービスを呼び出すためにAPEX_WEB_SERVICE APIを使用します。 ADFビジネス・コンポーネント・サービスの参照を定義するには、次のような値を使用します。
  • URL: https://(ICDomain,Incentive Compensation)/icCnSetupCreditRulesPublicService/CreditRuleService?WSDLなど。

  • 処理: サービスと操作(名前空間を含む)を定義します。 たとえば、{http://xmlns.oracle.com/apps/incentiveCompensation/cn/creditSetup/creditRule/creditRuleService/}RuleAttributeです。

  • 基本認証: これを有効にして、セキュリティ保護されたサービスに資格証明を渡します。

  • SOAPエンベロープ: サービスに渡すコンテンツを定義します。

  • コレクションに応答を格納: Webサービス・コールからの応答を保持する一時構造。 このオブジェクトを使用して、アプリケーションで使用される応答XMLを解析します。

関連トピック
  • Javaクライアント
  • .NET Framework
  • PHP
  • Perl
  • Python
  • Ruby
  • SOAP Webサービスの呼出し