【问题标题】:Not able to get Exception message from SOAP call using service reference .net无法使用服务参考.net 从 SOAP 调用中获取异常消息
【发布时间】:2018-02-02 15:36:21
【问题描述】:

我在 .NET 中使用服务引用来调用第三方运营商 API,即 ESTES。您可以找到 wsdl here。现在,每当我从代码中调用它并且出现一些错误时,它只会抛出一个 FaultException 和异常消息作为 GeneralErrorMsg 或 SchemavalidationError,而没有任何有意义的消息。当我在 SOAP UI 工具中运行它而不是从 .Net 代码中运行它时,我确实收到了有意义的消息。

以下是一些异常图像的链接。仅供参考,内部异常为空

Exception Stack Trace Image

Exception Data Property Image

以下是我使用 SOAPUI 运行 API 时得到的响应。仅供参考,这是第三方 API,不是我们的,我只是在调用他们的 API

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Server</faultcode>
         <faultstring>GeneralErrorMsg</faultstring>
         <detail>
            <bol:generalError xmlns:bol="http://ws.estesexpress.com/bol">
               <bol:error>
                  <bol:code>BOL0193</bol:code>
                  <bol:message>We cannot automatically assign a PRO number if the shipping address is not serviced       directly by Estes.  Please   uncheck the "Assign PRO #" box.  Questions?  Feel free to call your &lt;a href="/WebApp/TerminalList/"> local terminal&lt;/a>.</bol:message>
               </bol:error>
               <bol:error>
                  <bol:code>BOL0101</bol:code>
                  <bol:message>Invalid state/zip combination</bol:message>
               </bol:error>
            </bol:generalError>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

请帮帮我,这真的让我很难过。

【问题讨论】:

  • 你能解决这个问题吗?我也有同样的问题。

标签: c# .net service-reference faultexception


【解决方案1】:

尝试在托管服务的 web.config 文件中添加服务行为

<behavior name="faultBehavior">
          <serviceDebug includeExceptionDetailInFaults="true" />
</behavior>

但这在安全性方面还有其他缺点。

【讨论】:

  • 感谢您帮助拉胡尔。但它不是我们的第三方服务。我也添加了从 API 获得的响应。你能看看它并帮助我。再次感谢你
  • hmm,我可以知道“**当我在 SOAP UI 工具中运行它时,我确实得到了有意义的消息**”你得到的确切消息?
  • 示例这来自我在 SOAP UI 中运行它时的 API 响应:如果 Estes 不直接提供送货地址,我们将无法自动分配 PRO 编号。请取消选中“分配 PRO #”框。问题?随意调用您的 <a href="/WebApp/TerminalList/"> 本地终端</a> 这是一条有意义的消息。不是 schemaValidationError 或 GeneralErroMessage。
  • 理想情况下 FaultException 详细属性应该已捕获消息。是httpbinding吗?我的意思是有没有办法在客户端反序列化之前捕获 http 响应(比如使用开发人员工具)以查看确切的 SOAP 主体
  • 当您从工具和 .Net 代码调用时,您确定请求完全相同吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多