无法使用dotnetopenauth从Web服务调用Web服务

时间:2012-07-06 08:27:12

标签: web-services soap dotnetopenauth

我目前正在设置一个wcf SOAP Web服务,该服务使用OAuth v1(DotNetOpenAuth)来自动化用户。我通过IIS7在远程服务器上托管该站点。最近我成功地让网络服务返回用户的时间表,这就像一个魅力。

但是,现在我还需要能够通过此Web服务检索用户的测试结果。为此,我的Web服务调用另一个,现有的Web服务来检索结果,然后对它们进行格式化并将它们返回给用户。

我首先创建了一个测试web服务来完成这项工作,它完美地工作 - 我在SoapUI中加载我的Web服务的wsdl文件,并返回所需的结果(通过调用其他web服务)。

但是,在将方法实现到实际项目中时,它会失败。显然,由web.config文件中的元素引起了一个hickup;

<configuration>
  ...
  <applicationSettings>
    <OAuthServiceProvider.Properties.Settings>
      <setting name="OAuthServiceProvider_Zuyd_OsirisService" serializeAs="String">
        <value>http://.../OsirisServices-OsirisServices/OsirisServicePort</value>
      </setting>
    </OAuthServiceProvider.Properties.Settings>
  </applicationSettings>
</configuration>

使用...作为IP地址和端口号。当我包含这段代码(通过添加Web引用自动生成)时,每当我尝试访问Web引用时,我都会收到错误消息“远程服务器返回错误:(500)内部服务器错误”网站上的其他文件,就此而言)。如果我不包含它,那么我可以访问网站上的文件就好了,但是,好吧,那么我显然无法调用第二个Web服务。

我对这段代码做错了吗?或者还有其他我缺少的东西?

我在下面提供了完整的错误文字;

Server Error in '/consumerexample/v3' Application.
--------------------------------------------------------------------------------

The remote server returned an error: (500) Internal Server Error. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[WebException: The remote server returned an error: (500) Internal Server Error.]
   System.Net.HttpWebRequest.GetResponse() +1485
   DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +508

[ProtocolException: Error occurred while sending a direct message or getting the response.]
   DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +1911
   DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request) +63
   DotNetOpenAuth.Messaging.Channel.GetDirectResponse(HttpWebRequest webRequest) +72
   DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request) +349
   DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage) +154
   DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage) +69
   DotNetOpenAuth.OAuth.ConsumerBase.PrepareRequestUserAuthorization(Uri callback, IDictionary`2 requestParameters, IDictionary`2 redirectParameters, String& requestToken) +193
   DotNetOpenAuth.OAuth.WebConsumer.PrepareRequestUserAuthorization(Uri callback, IDictionary`2 requestParameters, IDictionary`2 redirectParameters) +28
   OAuthConsumer.GetTimeTable.getAuthorizationButton_Click(Object sender, EventArgs e) in C:\Program Files\TimeTableWebService\consumer4\OAuthConsumer\GetTimeTable.aspx.cs:54
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

编辑:我应该注意,在我的测试网络服务(有效的网络服务)中,添加网络参考会导致以下代码块自动生成;

<appSettings>
  <add key="Zuyd.OsirisService" value="http://.../OsirisServices-OsirisServices/OsirisServicePort"/>
</appSettings>

我不知道为什么元素出现在测试Web服务中,而元素出现在实际的Web服务中。在这两种情况下,我只需右键单击项目名称并选择“添加Web引用”。

另一个编辑:正如我在第二篇评论中所解释的那样,appSettings元素与它无关,它是web.config中缺少的另一个元素。将该元素添加到我的web.config后,我收到以下错误

Server Error in '/consumerexample/v3' Application.
--------------------------------------------------------------------------------

Unable to connect to the remote server 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: Unable to connect to the remote server

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[FaultException`1: Unable to connect to the remote server]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +348
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1421
   OAuthConsumer.SampleServiceProvider.IZuydWebservice.GetTestResults(Boolean filtered) +0
   OAuthConsumer.SampleServiceProvider.DataApiClient.GetTestResults(Boolean filtered) in C:\Program Files\TimeTableWebService\consumer4\OAuthConsumer\Service References\SampleServiceProvider\Reference.cs:435
   OAuthConsumer.GetTimeTable.<btnGetTestResults_Click>b__8(DataApiClient client) in C:\Program Files\TimeTableWebService\consumer4\OAuthConsumer\GetTimeTable.aspx.cs:115
   OAuthConsumer.GetTimeTable.CallService(Func`2 predicate) in C:\Program Files\TimeTableWebService\consumer4\OAuthConsumer\GetTimeTable.aspx.cs:141
   OAuthConsumer.GetTimeTable.btnGetTestResults_Click(Object sender, EventArgs e) in C:\Program Files\TimeTableWebService\consumer4\OAuthConsumer\GetTimeTable.aspx.cs:115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

0 个答案:

没有答案