次の単純化された XML スキーマ コレクションを検討してください。
CREATE XML SCHEMA COLLECTION CD.AcceptMessageSchema AS '
<xs:schema xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/Submit"
xmlns:ns1="http://schemas.microsoft.com/Sql/2008/05/Procedures/Submit"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
targetNamespace="http://schemas.microsoft.com/Sql/2008/05/Procedures/Submit"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="AcceptMessage">
<xs:complexType>
<xs:sequence>
<xs:element name="MessagePayload" type="xs:string"/>
<xs:element name="PatientIdentifiers">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="ID" type="ID">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
および次のストアド プロシージャ定義
create procedureSubmit.AcceptMessage_DEV @AcceptMessage xml(CD.AcceptMessageSchema)
as
Insert into blah...
...stored proc guts go here...
1 つのパラメーターがスキーマ コレクションに関連付けられて定義されていることがわかります。私の仮定では、SchemaCollection への関連付けがあれば、次のようなものを送信してストアド プロシージャを呼び出すことができます。
<AcceptMessage xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/Submit" xmlns:biztalk="http://InteriorHealth.BizTalk.CDX.Schemas.SQLSubmit.AcceptMessage" xmlns:ns0="http://microsoft.com/HealthCare/HL7/2X" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MessagePayload>
<![CDATA[somepayloaddata]]>
</MessagePayload>
<PatientIdentifiers>
<ID OID="2.16.840.1.113883.4.50" Value="3454545" AssigningAuthorityName="Patient Health Number" />
<ID OID="2.16.840.1.113883.3.277.1.73" Value="4545454" AssigningAuthorityName="Patient EMR Number" />
</PatientIdentifiers>
</AcceptMessage>
WCF-SQL 送信ポートで機能します。
奇妙なことに、SSMS でストアド プロシージャを呼び出すと、次のようになります。
EXEC Submit.AcceptMessage @AcceptMessage = ' <AcceptMessage xmlns="http://schemas.microsoft.com/Sql/2008/05/Procedures/Submit" xmlns:biztalk="http://InteriorHealth.BizTalk.CDX.Schemas.SQLSubmit.AcceptMessage" xmlns:ns0="http://microsoft.com/HealthCare/HL7/2X" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MessagePayload>
<![CDATA[somepayloaddata]]>
</MessagePayload>
<PatientIdentifiers>
<ID OID="2.16.840.1.113883.4.50" Value="3454545" AssigningAuthorityName="Patient Health Number" />
<ID OID="2.16.840.1.113883.3.277.1.73" Value="4545454" AssigningAuthorityName="Patient EMR Number" />
</PatientIdentifiers>
</AcceptMessage>';
正常に動作しますが、WCF-SQL 経由で送信するとエラーが発生します。
The start element with name "MessagePayload" and namespace "http://schemas.microsoft.com/Sql/2008/05/Procedures/Submit" was unexpected. Please ensure that your input XML conforms to the schema for the operation.
これは、XML スキーマ コレクションを適用してストアド プロシージャを次のように定義する前と同じです。
create procedureSubmit.AcceptMessage_DEV
@MessagePayload xml,
@PatientIdentifiers xml
as
上記のようなリクエストを送信すると、次のエラーが発生します。
The start element with name "ID" and namespace "http://schemas.microsoft.com/Sql/2008/05/Procedures/Submit" was unexpected. Please ensure that your input XML conforms to the schema for the operation.
<ID>
要素内の要素をどうするかわからなかったからです<PatientIdentifiers>
。
以前はすべてのパラメーター データを CDATA タグでラップしていましたが、機能していましたが、機能する場合は追加のスキーマ検証が必要でした。
これは、WCF-SQL を呼び出すときに、基本的にパラメーター要素内のすべてを CDATA にする必要があるということですか、それとも何か不足しているのでしょうか?
また、これはメッセージングのみのソリューションであり、オーケストレーションはありません。
ネストされた XML を SQL ストアド プロシージャに送信して、それを解析し、データをテーブルに挿入するにはどうすればよいですか?