コンマ区切りの値 (およびそのラベル) の文字列をメモリから読み取り、それらを XML ファイルにパッケージ化して送信するサービスを作成しています。関連する XSD ファイルは、各 XML 構造を持つデータ所有者によって生成されています。.txt
Web サービス経由で XML を送信する前に、XSD ファイルを読み込んで、ファイル内のデータ ラベルのリストを検証したいと考えています。XSD と txt ファイルの間で不一致が検出された場合、コードで例外をスローするようにしたいと考えています。一致が成功すると、.txt
ファイル、パッケージから値を取得し、XML 要求を送信します。これを行う方法のプロセス全体 (入力から出力まで) の例を探しています。
入力ファイルを読み取り、属性と値を収集します (TestValuesIN.txt)
"test.Foo", 122;
XSD ファイルを開き、入力ファイルの要素のリストに対して要素を 1 対 1 で照合します。今のところ、XSD に存在する "Test.Foo" (要素: Test.Foo val:) だけを気にします。(TextXSD.xsd)
<?xml version="1.0"?>
<!-- Generated using Flame-Ware Solutions XML-2-XSD v2.0 at http://www.flame-ware.com/Products/XML-2-XSD/ -->
<xs:schema id="batch-execution" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="batch-execution" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="insert">
<xs:complexType>
<xs:sequence>
<xs:element name="test.Foo" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="val" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="fire-all-rules">
<xs:complexType>
<xs:attribute name="max" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="get-objects">
<xs:complexType>
<xs:attribute name="out-identifier" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
次に、XML をポストします。
http://mycamelhump.<myurl>.com:8080/drools-camel-service/kservice/CommTestXML/execute
URI
<batch-execution>
<insert>
<test.Foo>
<val>122</val>
</test.Foo>
</insert>
<fire-all-rules max="-1"/>
<get-objects out-identifier="also-foo"/>
</batch-execution>
コードは結果を取得し、出力を (TestValuesOUT.txt) に出力します。
"Test.Foo", 100;