機械翻訳について

コールWebサービスおよびプロセス・レスポンス

任意の開発ツールを使用してwebサービスをコールし、レスポンスを処理します。

Webサービスの呼出し

  1. webサービスを呼び出すには、ブラウザ、Soap UIまたはその他の開発ツールでURLを使用します。

    http://hostname:port/ctoUtilitiesPublicService/ConfiguredItemService
  2. 操作のリストから、findCtoItemStructure、findCtoSalesStructure、refreshConfigStructureまたはdeleteConfigStructureを選択します。

  3. ペイロードを入力します。

  4. 「呼び出す」をクリックします。

レスポンスの処理

様々な方法を使用してレスポンスを処理します。

SQLの使用

  1. プロキシを使用してwebサービスをコールします。

  2. レスポンスの各行のレスポンスをリレーショナル・データベース表に格納します。

    2つの表を作成します。

    • 表CTO_ITEM_STRUCTUREには、レスポンスの各属性の列が含まれます。

    • 表CTO_TRANSACTION_ATTRには、トランザクション属性の値が格納されます。 また、LINE_ID属性に従ってCTO_ITEM_STRUCTUREへの外部キーも含まれます。

    たとえば:

    2つの表を作成します。
  3. SQLを使用して表を問い合せ、レスポンスの詳細を取得します。

    SELECT * FROM CTO_ITEM_STRUCTURE WHERE <CONDITION>

JavaおよびSQLの使用

  1. プロキシを使用してサービスを呼び出します。

  2. レスポンスの各行をXMLに変換します。

    変換に使用するJavaコードの例を次に示します。

    JAXBContext contextObj = JAXBContext.newInstance(new Class[] {
      CtoItemStructure.class
    });
    Marshaller marshallerObj = contextObj.createMarshaller();
    marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JAXBElement < CtoItemStructure > rootElement = new JAXBElement < CtoItemStructure > (new QName("CtoItemStructureRow"), CtoItemStructure.class, opTempList.get(Index));
    marshallerObj.marshal(rootElement, baos);
    String xmlContent = new String(baos.toByteArray());
    ClobDomain objClobDomain = new ClobDomain(xmlContent);
    
  3. データをCTO_ITEM_STRUCTURE表に格納します。 この構造を使用します。

    属性名

    タイプ

    説明

    CONFIG_ITEM_ID

    Long

    構成品目を識別する値です。

    ITEM_STRUCTURE

    Clob

    行のXMLデータ。 これはJavaコードの出力です。

  4. SQLを使用して表を問い合せます。

    たとえば:

    select CONFIG_ITEM_ID,
    extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /ConfigItemId ')CONFIG_ITEM_ID,
    extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /ConfigItemNumber ')CONFIG_ITEM_NUMBER, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /BaseModelId ')BASE_MODEL_ID, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /BaseModelItemNumber ')BASE_MODEL_ITEM_NUMBER, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /InventoryItemId ') INVENTORY_ITEM_ID, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /InventoryItemNumber ')INVENTORY_ITEM_NUMBER, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /LineId ')LINE_ID,
    extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /ParentLineId ')PARENT_LINE_ID, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /SubItemType ') SUB_ITEM_TYPE, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /OptionalComponent') OPTIONAL_COMPONENT, extractvalue(ITEM_STRUCTURE,'/ CtoItemStructureRow /ComponentHierarchy ')COMPONENT_HEIRARCHY from CTO_ITEM_STRUCTURE where CONFIG_ITEM_ID =<CONFIGURED ITEM ID>

レスポンスの書式設定

webサービスのXML出力は、親子関係に従って階層的にインデントまたは編成されません。 XSLT (Extensible Stylesheet Language Transformations)スタイル・シートを使用して、webサービスのレスポンスを書式設定し、階層をビジュアル化できるようにします。

レスポンスの書式設定に使用できるXSLTコードを次に示します。 お気に入りのXMLツールでこのコードを使用します。

< xsl: stylesheet version = "1.0"
 xmlns: xsl = "http://www.w3.org/1999/XSL/Transform"
 xmlns: ns0 = "http://xmlns.oracle.com/apps/scm/cto/matchRepository/utilities/configItemStructureSer
 vice / types / "
 xmlns: ns2 = "http://xmlns.oracle.com/apps/scm/cto/matchRepository/utilities/configItemStructureSer vice/types/"
 xmlns: ns1 = "http://xmlns.oracle.com/apps/scm/cto/matchRepository/utilities/configItemStructureSer
 vice / "
 xmlns: env = "http://schemas.xmlsoap.org/soap/envelope/"
 xmlns: wsa = "http://www.w3.org/2005/08/addressing"
 xmlns: typ = "http://xmlns.oracle.com/apps/scm/cto/matchRepository/utilities/configItemStructureService/types/ " >
   <
   xsl: output method = "xml"
 indent = "yes"
 version = "1.0"
 encoding = "UTF-8" / >
   <
   xsl: template match = "*" >
   <
   xsl: element name = "{local-name()}" >
   <
   xsl: if test = "not(not(text()) and not(node()))" >
   <
   xsl: apply - templates select = " node()" / >
   <
   / xsl : if > <
   / xsl : element > <
   / xsl : template > <
   xsl: template match = "env:Envelope" >
   <
   xsl: apply - templates select = "env:Body" / >
   <
   / xsl : template > <
   xsl: template match = "env:Body" >
   <
   xsl: apply - templates select = " ns0:findCtoItemStructureResponse | ns0:findCtoItemStructureAsyncResponse " / >
   <
   / xsl : template > <
   xsl: template match = "ns0 ns0:findCtoItemStructureResponse | ns0:findCtoItemStructureAsyncResponse" >
   <
   xsl: copy >
   <
   xsl: apply - templates select = ".//ns2:result[not(ns1:ParentLineId/node())]" / >
   <
   / xsl : copy > <
   / xsl : template > <
   xsl: template match = "ns2:result" >
   <
   xsl: variable name = "LineId"
 select = "./ns1:LineId" / >
   <
   xsl: variable name = "OrganizationId"
 select = "./ns1:OrganizationId" / >
   <
   xsl: variable name = "InventoryItemId"
 select = "./ns1:InventoryItemId" / >
   <
   xsl: variable name = "ComponentItemHierarchy"
 select = "./ns1:ComponentItemHierarchy" /
   >
   <
   xsl: element name = "ns2:result" >

   <
   xsl: apply - templates select = "node()" / >
   <
   xsl: if test = "../ns2:result[(./ns1:ParentLineId = $LineId and ./ns1:OrganizationId =
 $OrganizationId and concat($ComponentItemHierarchy, '-', . / ns1: InventoryItemId) =
   . / ns1: ComponentItemHierarchy)]
 ">

 <
 xsl: apply - templates select = "../ns2:result[(./ns1:ParentLineId = $LineId and
   . / ns1: OrganizationId = $OrganizationId)]
 " /> <
 / xsl : if > <
 / xsl : element > <
 xsl: variable name = "nl"
 select = "'
'" / >
   <
   xsl: value - of select = "$nl"
 disable - output - escaping = "no" / >
   <
   / xsl : template > <
   / xsl : stylesheet >

このXSLTコードは、findCtoItemStructure操作の出力の書式設定にのみ使用します。

かわりに、レスポンスをプログラム的に書式設定するために使用できるコード例を次に示します。

String xml = "input.xml ; // input XML file location 
String xslt = "transformations.xsl"; // XSLT file location
String output = "formatted.xml"; //output XML file location 
  TransformerFactory tf = TransformerFactory.newInstance(); 
  Transformer tr = tf.newTransformer(new StreamSource(new File(xslt))); 
  tr.transform(new StreamSource(new File(xml)),