2017-03-08 3 views
0

をCSVファイルにDSSからの応答を記述する方法:WSO EI6-どのように私は以下のようにデータサービスGetDepartmentDataサービスを作成した

<data enableBatchRequests="true" name="GetDepartmentDataService" transports="http https local"> 
    <config enableOData="false" id="LocalXEDS"> 
     <property name="carbon_datasource_name">LocalXEDB</property> 
    </config> 
    <query id="GetDeptQuery" useConfig="LocalXEDS"> 
     <sql>select dept_id,name,location from dept&#xd;where dept_id=?</sql> 
     <result element="Departments" rowName="Department"> 
     <element column="dept_id" name="dept_id" xsdType="string"/> 
     <element column="name" name="name" xsdType="string"/> 
     <element column="location" name="location" xsdType="string"/> 
     </result> 
     <param name="dept_id" sqlType="INTEGER"/> 
    </query> 
    <operation name="GetDepartment_Operation"> 
     <description> Returns the departments for the given department id.                  &#xd;         </description> 
     <call-query href="GetDeptQuery"> 
     <with-param name="dept_id" query-param="dept_id"/> 
     </call-query> 
    </operation> 
</data> 

を私はデータのWSDLエンドポイント「MyEP」を作成しました私はこのデータサービスを呼び出すためにESBを作成しました。そして、私はCSVファイルでレスポンスを書きました。私は以下のログメッセージとエラーを取得しています

<payloadFactory media-type="xml"> 
       <format> 
        <dat:GetDepartment_Operation xmlns:dat="http://ws.wso2.org/dataservice"> 
         <dat:dept_id>$1</dat:dept_id> 
        </dat:GetDepartment_Operation> 
       </format> 
       <args> 
        <arg evaluator="xml" expression="//soapenv:Envelope/soapenv:Body/dat:GetDepartment_Operation/dat:dept_id" xmlns:dat="http://ws.wso2.org/dataservice" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"/> 
       </args> 
      </payloadFactory> 
      <call> 
       <endpoint key="myEP"/> 
      </call> 
      <log level="full"/> 
      <property name="transport.vfs.ReplyFileURI" scope="transport" type="STRING" value="file:///C:/Shilpa/sourcecode/FileConnector/Inbound?transport.vfs.Append=true"/> 
      <property name="transport.vfs.ReplyFileName" scope="transport" type="STRING" value="order.csv"/> 
      <property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/> 
      <property name="REST_URL_POSTFIX" scope="axis2" type="STRING" value=""/> 

      <property name="OUT_ONLY" scope="default" type="STRING" value="true"/> 
      <datamapper config="gov:datamapper/DBReadWritePSconfig.dmc" inputSchema="gov:datamapper/DBReadWritePSconfig_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/DBReadWritePSconfig_outputSchema.json" outputType="CSV"/> 
      <call> 
       <endpoint> 
        <address uri="vfs:file:///C:/Shilpa/sourcecode/FileConnector/Inbound/order.csv"/> 
       </endpoint> 
      </call> 

 WARN - XMLInputReader Element name not found : axis2ns5:Departments 
[2017-03-08 21:00:36,240] [] ERROR - DataMapperMediator DataMapper mediator : mapping failed 
Input type is incorrect or Invalid element found in the message payload : axis2ns5:Departments 

答えて

0

それが唯一の部門のノードが含まれるようにあなたはペイロードを変更する必要がありますDataMapperのメディエーター前に、以下の同じのためのコードです。豊かなメディエーターは次のように使用できます。

... 
<enrich> 
      <source xmlns:p="http://ws.wso2.org/dataservice" 
        clone="true" 
        xpath="$body//p:Departments/*[1]"/> 
      <target type="body"/> 
     </enrich> 
<datamapper config="gov:datamapper/DBReadWritePSconfig.dmc" inputSchema="gov:datamapper/DBReadWritePSconfig_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/DBReadWritePSconfig_outputSchema.json" outputType="CSV"/> 
... 
+0

感謝...私はエンリッチメディエーターに挑戦しましたが、それでも今でも部門のために同じエラーを喚起しています。 ERROR - DataMapperMediator DataMapperメディエータ:マッピングに失敗しました 入力タイプが正しくないか、メッセージペイロードに無効な要素が見つかりました:axis2ns5:Department – Shilpa

+0

この場合、私の環境でシナリオを再現するためにdatamappingの設定を表示する必要があります。 – Ernesto

+0

ここに私の答えの私のデータマッピング構成です。 – Shilpa

0
map_S_Envelope_S_root = function(){ 
var outputroot={}; 

var count_i_Department = 0; 
outputroot = {}; 
outputroot.Departments = {}; 
outputroot.Departments.Department = {}; 

for(i_Department in inputsoapenv_Envelope.soapenv_Body.Departments.Department){ 
outputroot.Departments.Department.dept_id = inputsoapenv_Envelope.soapenv_Body.Departments.Department[i_Department].dept_id; 
outputroot.Departments.Department.name = inputsoapenv_Envelope.soapenv_Body.Departments.Department[i_Department].name; 
outputroot.Departments.Department.location = inputsoapenv_Envelope.soapenv_Body.Departments.Department[i_Department].location; 

count_i_Department++; 
} 
return outputroot; 
}; 
+0

私の場合、それはmap_S_Department_S_Departments = function(){ です。var outputDepartments = {}; outputDepartments = {}; outputDepartments.Department = {}; outputDepartments.Department.dept_id = inputDepartment.dept_id; outputDepartments.Department.name = inputDepartment.name; outputDepartments.Department.location = inputDepartment.location; return outputDepartments; }; – Ernesto

+0

ありがとう...データマッパーで使用した入力ファイルと出力ファイルを共有してください。 – Shilpa

0

マイ入力ファイルの例(XML)

<?xml version="1.0" encoding="UTF-8"?> 
    <Department> 
     <dept_id>1</dept_id> 
     <name>dep1</name> 
     <location>loc1</location> 
    </Department> 

マイ出力ファイル例(CSV)

id_dept、名前、場所 1、DEP1、LOC1

私の入力スキーマ

{ 
    "$schema" : "http://wso2.org/json-schema/wso2-data-mapper-v5.0.0/schema#", 
    "id" : "http://wso2jsonschema.org", 
    "title" : "Department", 
    "type" : "object", 
    "properties" : { 
    "dept_id" : { 
     "id" : "http://wso2jsonschema.org/dept_id", 
     "type" : "number" 
    }, 
    "name" : { 
     "id" : "http://wso2jsonschema.org/name", 
     "type" : "string" 
    }, 
    "location" : { 
     "id" : "http://wso2jsonschema.org/location", 
     "type" : "string" 
    } 
    } 
} 

マイOutputSchema

{ 
    "$schema" : "http://wso2.org/json-schema/wso2-data-mapper-v5.0.0/schema#", 
    "id" : "http://wso2jsonschema.org", 
    "title" : "Departments", 
    "type" : "object", 
    "properties" : { 
    "Department" : { 
     "id" : "http://wso2jsonschema.org/Department", 
     "type" : "object", 
     "properties" : { 
     "dept_id" : { 
      "id" : "http://wso2jsonschema.org/Department/dept_id", 
      "type" : "number" 
     }, 
     "name" : { 
      "id" : "http://wso2jsonschema.org/Department/name", 
      "type" : "string" 
     }, 
     "location" : { 
      "id" : "http://wso2jsonschema.org/Department/location", 
      "type" : "string" 
     } 
     } 
    } 
    }, 
    "namespaces" : [ { 
    "prefix" : "axis2ns4", 
    "url" : "http://ws.wso2.org/dataservice" 
    } ] 
} 
+0

Ernestoに感謝、今働いています。しかし、1つのレコードに対してのみ機能します。複数のレコードがフェッチされた場合は、CSVファイルの最後のレコードだけが書き込まれます。 – Shilpa

0

そのWORKING!エルネスト@

は ..あなたの助けのためにどうもありがとうございます、私は以下のように私のDMCを変更し、それは...絶対に正常に動作している

map_S_Departments_S_Departments = function(){ 
var outputDepartments={}; 

var count_i_Department = 0; 
outputDepartments = {}; 
outputDepartments.Department = []; 

for(i_Department in inputDepartments.Department){ 
outputDepartments.Department[count_i_Department] = {}; 
outputDepartments.Department[count_i_Department].dept_id = inputDepartments.Department[i_Department].dept_id; 
outputDepartments.Department[count_i_Department].name = inputDepartments.Department[i_Department].name; 
outputDepartments.Department[count_i_Department].location = inputDepartments.Department[i_Department].location; 

count_i_Department++; 
} 
return outputDepartments; 
}; 

出力:お返事エルネストため

110.0,PRODUCTION SUPPORT,MONTEREY, CA 
110.0,DOCUMENTATION,WEXFORD, PA 
110.0,ABC,wer 
関連する問題