【问题标题】:BizTalk Server 2013 - Web Reference to ASMX - elements in the Response unavailable in BizTalk Expression EditorBizTalk Server 2013 - 对 ASMX 的 Web 引用 - BizTalk 表达式编辑器中的响应中的元素不可用
【发布时间】:2014-12-29 22:19:30
【问题描述】:

我正在导入并在 BTS 2013 中重新编译一个 BTS 2009 项目,以保持在 Microsoft 支持生命周期内。

这是由以前的开发人员在 Windows XP 上使用 BTS 2009、Visual Studio 2008 开发的,后来转移到 Windows 7。编译后的解决方案部署在 Windows 2008 R2 服务器中。在本练习中,我在 Windows 7 上使用 Visual Studio 2013、BizTalk Server 2013 和最新的 Service Pack。

该解决方案有四个项目 - 一个用于架构、地图、管道和编排。

架构项目引用 .ASMX Web 服务,作为“Web 参考”(不是服务参考)。 ASMX 的响应 XML 如下所示:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GenerateSalesIDResponse xmlns="http://Company.Integration.SalesIDGenerator/">
      <GenerateSalesIDResult>
        <SalesID>string</SalesRefID>
        <SalesIDInASCII>string</SalesRefIDInASCII>
        <IsError>boolean</IsError>
        <ErrorMessage>string</ErrorMessage>
        <StackTrace>string</StackTrace>
      </GenerateSalesIDResult>
    </GenerateSalesIDResponse>
  </soap12:Body>
</soap12:Envelope>

在其中一个编排中,有一个消息分配形状,其表达式如下:

Msg_OrderOutputForHTML.Exception = Msg_SalesRefIDResponse.GenerateSalesIDResult.ErrorMessage;
Msg_OrderOutputForHTML.StackTrace = Msg_SalesRefIDResponse.GenerateSalesIDResult.StackTrace;

摆在我面前的问题是,上述 XML 中的元素 ErrorMessageStackTrace 及其所有同级元素都不适用于 BizTalk 表达式编辑器。 Intellisense 可以在 GenerateSalesIDResult 之前工作,但在那之后,对于之后的任何 XML 元素都不能。

错误信息是-identifier 'StackTrace' does not exist in 'Msg_SalesIDReponse.GenerateSalesIDResult'; are you missing an assembly reference?

我应该怎么做才能解决这个问题?请帮忙。

注意 - 我知道不再推荐使用 ASMX,但是将其更改为等效的 WCF 服务将需要我做大量的非技术工作 :-)

更新 1:

Reference.xsd 如下所示:

<?xml version="1.0"?>
<xs:schema xmlns:tns="http://Company.Integration.SalesIDGenerator/" elementFormDefault="qualified" targetNamespace="http://Company.Integration.SalesIDGenerator/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="SalesIDGen" nillable="true" type="tns:SalesIDGen" />
  <xs:complexType name="SalesIDGen">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="1" name="SalesID" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="SalesIDInASCII" type="xs:string" />
      <xs:element minOccurs="1" maxOccurs="1" name="IsError" type="xs:boolean" />
      <xs:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="StackTrace" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>

更新 2: 如果我在 VS2008 中打开相同的项目,则不会出现此问题。

【问题讨论】:

    标签: visual-studio-2013 asmx biztalk biztalk-2013 biztalk-orchestrations


    【解决方案1】:

    消息是强类型的,似乎没有正确生成模式的类,因此无法识别子节点。为 Web 参考生成的架构是什么样的?

    您可以尝试更新网络参考并重建项目。同时关闭并重新打开 Visual Studio。

    更新:

    有关在编排中访问消息内容的其他方式,请查看https://code.msdn.microsoft.com/windowsdesktop/BizTalk-Accessing-and-0cd434f7

    您可以尝试使用 XPath 表达式来获取消息内容。

    所以

    Msg_OrderOutputForHTML.Exception = Msg_SalesRefIDResponse.GenerateSalesIDResult.ErrorMessage;
    

    应该是这样的

    Msg_OrderOutputForHTML.Exception = xpath(msgOutput3,"string(/*[local-name()='GenerateSalesIDResponse' and namespace-uri()='http://Company.Integration.SalesIDGenerator/']/*[local-name()='GenerateSalesIDResult']/*[local-name()='ErrorMessage'])")
    

    【讨论】:

    • 谢谢@Gruff 我在原始问题的更新中添加了 Reference.xsd 的内容。我已经删除并重新添加了 Web 参考,关闭并重新打开了 VS2013,清理了解决方案和项目。毕竟错误仍然存​​在。
    • 很遗憾我还没有使用 VS2013 进行 BizTalk 开发。您能否确认 Web 参考生成器生成了一个 Reference.map.cs 文件并且您尝试访问的元素标有DistinguishedFieldAttribute?我用其他访问消息内容的方式更新了答案,供您阅读。
    • 是的,我可以在Reference.map.cs 文件中看到,有一个public partial class,其中所有元素都标有Microsoft.XLANGs.BaseTypes.DistinguishedFieldAttribute()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多