简体   繁体   English

DotNetOpenAuth在WCF中引发错误

[英]DotNetOpenAuth throwing an error in WCF

I'm using a third party library to fetch a collection of items The API is based on DotNetOpenAuth. 我正在使用第三方库来获取项目集合。该API基于DotNetOpenAuth。

The api call to fetch data works fine when tested through a simple console application. 通过简单的控制台应用程序进行测试时,用于获取数据的api调用可以正常工作。

However, My goal is to use this API within a web service. 但是,我的目标是在Web服务中使用此API。 When I test my Web service, the same API call to fetch data throws an exception: 当我测试我的Web服务时,用于获取数据的相同API调用将引发异常:

"Error occurred while sending a direct message or getting the response." “发送直接消息或获取响应时发生错误。”

and the error code is 500 . 错误代码为500。

I find it strange that the same API call works from a console app but not from a web service call. 我感到奇怪的是,同一API调用可从控制台应用程序运行,但不能通过Web服务调用运行。 Help! 救命!

the webconfig: webconfig:

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

I figured out what was going on. 我知道发生了什么事。

1) in the API, I was requesting for paged results, and it does not start with 0. It worked when I sent > 1 as the page offset. 1)在API中,我正在请求分页结果,它不是以0开头。当我发送> 1作为页面偏移量时,它可以工作。

2) I should have noticed that underneath this ambiguous error message, a server error code (500) was being returned . 2)我应该已经注意到,在此模棱两可的错误消息下,正在返回服务器错误代码(500)。 90% of the time it means your sending crap to the server hehe. 90%的时间意味着您将废话发送到服务器。

problem solved! 问题解决了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM