【问题标题】:xpath query not working in BizTalk orchestrationxpath 查询在 BizTalk 业务流程中不起作用
【发布时间】:2013-11-06 20:49:35
【问题描述】:

我正在尝试重写 BizTalk 2010 应用程序并取消外部程序集,但我似乎遇到了 xpath 问题。

我们有一个将医疗保健索赔 (837P) 以 xml 形式存储在数据库中的流程,我们需要稍后将其提取出来。我有一个 WCF 端口调用一个存储过程,该过程返回一个看起来像这样的 xml 消息:

<ClaimXml_SEL_GetClaimXmlResponse xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo">
   <StoredProcedureResultSet0>
      <StoredProcedureResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/ProceduresResultSets/dbo/ClaimXml_SEL_GetClaimXml">
         <Claim><![CDATA[<ns0:X12_00401_837_P (etc.)

所以我需要做的是提取实际的 837P 消息 - 以 ns0:X12_00401_837_P 开头的部分。

帮助类很简单,就是有这样一个方法:

public XmlDocument ExtractClaimXml(XmlDocument xDoc)
{
   XmlDocument xReturn = new XmlDocument();

   XmlNode node = xDoc.SelectSingleNode("/*[local-name()='ClaimXml_SEL_GetClaimXmlResponse' and namespace-uri()='http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo']/*[local-name()='StoredProcedureResultSet0' and namespace-uri()='http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo']/*[local-name()='StoredProcedureResultSet0' and namespace-uri()='http://schemas.microsoft.com/Sql/2008/05/ProceduresResultSets/dbo/ClaimXml_SEL_GetClaimXml']/*[local-name()='Claim' and namespace-uri()='http://schemas.microsoft.com/Sql/2008/05/ProceduresResultSets/dbo/ClaimXml_SEL_GetClaimXml']");

   xReturn.LoadXml(node.InnerText);

   return xReturn;
}

然后消息分配形状有这个代码:

rawClaimXml = ClaimXmlResponse;
strippedClaim = XmlHelperClass.ExtractClaimXml(rawClaimXml);
Claim837P = strippedClaim;

...ClaimXmlResponse;就是上面显示的消息,Claim837P是837P消息,rawClaimXml & strippedClaim是xml变量。这工作得很好,但调用外部程序集似乎有点过分。

我在 assingment 形状中尝试过这个:

rawClaimXml = xpath(ClaimXmlResponse, "same xpath as above");
strippedClaim.LoadXml(rawClaimXml.InnerText);
Claim837P = strippedClaim;

...但收到错误“'UnderlyingXmlDocument.InnerText': .NET 属性是只写的,因为它没有 get 访问器”。

然后我尝试从 xpath 查询中获取一个字符串:

rawClaimString = xpath(ClaimXmlResponse, "string(same xpath as above)");
rawClaimString = rawClaimString.Replace("<![CDATA[", "");
rawClaimString = rawClaimString.Replace(">]]>",">");
strippedClaim.LoadXml(rawClaimString);
Claim837P = strippedClaim;

...但这并不好。还尝试了一个变体:

rawClaimXml = xpath(ClaimXmlResponse, "same xpath as above");
rawClaimString = rawClaimXml.InnerXml.ToString();
rawClaimString = rawClaimString.Replace("<![CDATA[", "");
rawClaimString = rawClaimString.Replace(">]]>",">");
strippedClaim.LoadXml(rawClaimString);
Claim837P = strippedClaim;

...但还是不行。有什么建议吗?

谢谢!

【问题讨论】:

    标签: biztalk biztalk-2010


    【解决方案1】:

    1- 您可以尝试以下几件事:

    • 将 xpath 包装在 string() 函数中。 xpath(ClaimXmlResponse, "string(same xpath as above)");
    • /text() 节点附加到xpath。 xpath(ClaimXmlResponse, "same xpath as above/text()");
    • 两者的结合。

    您能详细说明这里的目标吗?使用辅助类没有任何问题。如果困扰您的是额外的程序集,您可以随时将 .cs 添加到 BizTalk 项目中。

    2- 从不同的方向来看,您可以在 WCF-Custom Adpater 配置的“消息”选项卡上为入站 BizTalk 消息正文使用路径选项。

    【讨论】:

      【解决方案2】:

      我也遇到了类似的问题,但是当我浏览了你的各种解决方案时,我得到了我的问题的解决方案。

      对我来说这很有效 **

      rawClaimString = xpath(ClaimXmlResponse, "string(与 xpath 相同 以上)");

      **

      谢谢你的声音;)

      为了解决您的问题,您可以区分提升持有您的响应的节点,并尝试使用 .notation 访问该节点并将其分配给 sting,这将向您返回预期的输出:)

      【讨论】:

        猜你喜欢
        • 2012-06-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-26
        • 1970-01-01
        • 2014-07-08
        • 2021-04-16
        • 1970-01-01
        相关资源
        最近更新 更多