2016-06-26 5 views
0

私の場合、localhost:8081/searchに行くと、テキストフィールド(入力)と送信ボタンがある単純なhtmlファイルをロードする必要があります。mule esbの.txtファイルにあるデータベースのクエリの結果を取得するには?

テキストフィールドに件名を入力し、送信ボタンをクリックすると、件名をデータベースに転送してSQLクエリを適用する必要があります。照会結果は.txtまたは.htmlというファイルで返されます。

しかし、私はテキストファイルを見ると、私は非常に珍しい文字を参照してください。

ラバのこの私のXMLフローコード

<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/> 
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" password="Blue1234" database="news" doc:name="MySQL Configuration"/> 
<http:request-config name="HTTP_Request_Configuration" host="localhost" doc:name="HTTP Request Configuration" port="8081"/> 
<file:connector name="file" writeToDirectory="C:\Users\Hersh\Desktop\file" autoDelete="true" streaming="true" validateConnections="true" doc:name="File" /> 
<flow name="parsetemplateFlow"> 
    <http:listener config-ref="HTTP_Listener_Configuration" path="/web" doc:name="HTTP"/> 
    <set-payload value="#[message.inboundProperties.'http.query.params'.q]" doc:name="Set Payload" mimeType="text/html"/> 
    <db:select config-ref="MySQL_Configuration" doc:name="Database"> 
     <db:parameterized-query><![CDATA[select txt from news.nws where sub=#[message.payload]]]></db:parameterized-query> 
    </db:select> 
    <response> 
     <http:static-resource-handler resourceBase="C:\Users\Hersh\Desktop\attach" defaultFile="index.html" doc:name="HTTP Static Resource Handler"/> 
    </response> 
    <logger message="#[message.payload]" level="INFO" doc:name="Logger"/> 
    <set-payload value="#[message.payload]" doc:name="Set Payload"/> 
    <response> 
     <file:outbound-endpoint path="C:\Users\Hersh\Desktop\file" outputPattern="output.txt" connector-ref="file" responseTimeout="10000" doc:name="File"/> 
    </response> 
</flow> 
</mule> 

、これは理想的にはあなたの流れの構造はこのようなものであるべき流れ

enter image description here

答えて

0

のスクリーンショットで、

  • 構文解析テンプレート/ HTTP静的リソースを使用してhtmlで入力しますハンドラ
  • これらの値をDBに使用
  • ファイルコンポーネントを使用してDBからの応答をファイルに書き込みます。

これはあなたが必要とするものではない場合は、コメントしてください。 uは珍しい文字を取得している理由です

<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/> 
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" password="Blue1234" database="news" doc:name="MySQL Configuration"/> 
<http:request-config name="HTTP_Request_Configuration" host="localhost" doc:name="HTTP Request Configuration" port="8081"/> 
<file:connector name="file" writeToDirectory="C:\Users\Hersh\Desktop\file" autoDelete="true" streaming="true" validateConnections="true" doc:name="File" /> 
<flow name="parsetemplateFlow"> 
    <http:listener config-ref="HTTP_Listener_Configuration" path="/web" doc:name="HTTP"/> 
     <http:static-resource-handler resourceBase="C:\Users\Hersh\Desktop\attach" defaultFile="index.html" doc:name="HTTP Static Resource Handler"/> 
     <set-payload value="#[message.inboundProperties.'http.query.params'.q]" mimeType="text/html" doc:name="Set Payload"/> 
    <db:select config-ref="MySQL_Configuration" doc:name="Database"> 
     <db:parameterized-query><![CDATA[select txt from news.nws where sub=#[message.payload]]]></db:parameterized-query> 
    </db:select> 
    <logger message="#[message.payload]" level="INFO" doc:name="Logger"/> 
    <set-payload value="#[message.payload]" doc:name="Set Payload"/> 
     <file:outbound-endpoint path="C:\Users\Hersh\Desktop\file" outputPattern="output.txt" connector-ref="file" responseTimeout="10000" doc:name="File"/> 
</flow> 
+0

私は私のプロジェクトに応募しなければなりません..! あなたはもっと説明することができます.. – hersh

+0

私はconfig.xml plzを作ってくれました。 – scorpion

0

データベースコネクタはjava.util.LinkedList(Javaのコレクション形式)の形式でデータを返すXMLベース

サンプル設定。プレーンテキストを取得する場合は 、まずデータをjavaオブジェクトからプレーンテキストに変換する必要があります。変換用の変換メッセージを使用できます。

+0

この変換メッセージは私の流れのどこに追加しなければならないのか説明できますか? – hersh

+0

あなたのデータのコンテンツサンプルをファイルに表示します。 – Deep

関連する問題