【问题标题】:Is there a standard way to structure a web method error message?有没有一种标准的方式来构建一个 web 方法错误消息?
【发布时间】:2010-11-08 22:25:22
【问题描述】:

我正在编写一个将 xhtml 文件发布到数据库的 Web 方法。该 Web 服务应该与技术无关(例如,支持 Java 应用程序)。发布方法返回一个字符串。在返回中,我想通知调用应用程序发布成功或失败。另外我想包括:

  • 解析错误集合
  • 无效值的集合(这取决于数据库中的匹配值)
  • 存在版本冲突时的消息

以下是我可以使用的一种格式。格式化 Web 方法返回值时,Web 服务开发人员是否遵循指南?谢谢。

 <result>
        <info name="successful" value="true"/>
        <info name="successtype" value="partial"/> 
        <info name="versionconflict" value="false"/>
        <parseErr>
            <err field="itemId" desc="Missing required element Item Id"/>
            <err field="content" desc="Required tag <content> is missing."/> 
            <err field="purchaseDate desc="Invalid date format. Date should be in mm-dd-yyyy."/>
        </parseErr>

        <failedAttributes>
            <err attribute="userName" value="NULL"/>
            <err attribute="orderCategory" value="Porduce"/>
        </failedAttributes>

    </result>

【问题讨论】:

    标签: c# .net service wcf


    【解决方案1】:

    您可以查看 SOAP 故障,而不是将故障信息作为合同方法返回值的一部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-21
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多