最近、私はIIS7でホストされているDotNetOpenAuth Webサービス経由でOAuthによって保護されているWCF SOAP Webサービスに取り組んできました。私は働くプロジェクトがあると言いますと、うれしく思います。つまり、httpで動作します。httpからhttpsへのWebサービスの移動
次のステップは、2つのプロジェクト(コンシューマとサービスプロバイダ、後者はWebサービスを含む)をhttpsに移動することです。しかし、これは少し問題を引き起こしています。
コンシューマからDataApi.svcを呼び出すと、次のエラーが発生します。
Server Error in '/consumerexample/v2' Application.
--------------------------------------------------------------------------------
The username is not provided. Specify username in ClientCredentials.
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.InvalidOperationException: The username is not provided. Specify username in ClientCredentials.
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:
[InvalidOperationException: The username is not provided. Specify username in ClientCredentials.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4727747
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
OAuthConsumer.SampleServiceProvider.IDataApi.retrieveTimeTable(String weekVan, String weekTot) +0
OAuthConsumer.SampleServiceProvider.DataApiClient.retrieveTimeTable(String weekVan, String weekTot) in C:\Program Files\TimeTableWebService\consumer\OAuthConsumer\Service References\SampleServiceProvider\Reference.cs:108
OAuthConsumer.<>c__DisplayClass6.<retrieveTimeTable_Click>b__5(DataApiClient client) in C:\Program Files\TimeTableWebService\consumer\OAuthConsumer\GetTimeTable.aspx.cs:76
OAuthConsumer.GetTimeTable.CallService(Func`2 predicate) in C:\Program Files\TimeTableWebService\consumer\OAuthConsumer\GetTimeTable.aspx.cs:129
OAuthConsumer.GetTimeTable.retrieveTimeTable_Click(Object sender, EventArgs e) in C:\Program Files\TimeTableWebService\consumer\OAuthConsumer\GetTimeTable.aspx.cs:76
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
httpでは、これは魅力的です。ローカルでコンシューマをデバッグすると、OAuth認証全体が美しく動作します。 DataApi.svc内のretrieveTimeTableメソッドが呼び出され、このエラーが発生した場合のみです。
私はIIS7で、匿名認証と基本認証の両方をコンシューマサイトとサービスプロバイダサイトの両方で有効にしました。 web.configファイルは次のとおりです。
消費者
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDataApi" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="999999999" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://websrv.hszuyd.nl/serviceprovider/v2/DataApi.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDataApi" contract="SampleServiceProvider.IDataApi" name="WSHttpBinding_IDataApi">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
サービスプロバイダ
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="DataApiBehavior">
<webHttp />
</behavior>
<behavior name="wsHttpEnablingBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DataApiBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization serviceAuthorizationManagerType="OAuthServiceProvider.Code.OAuthAuthorizationManager, OAuthServiceProvider" principalPermissionMode="Custom" />
</behavior>
<behavior name="wsHttpEnablingBehaviour">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding" maxReceivedMessageSize="999999999">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="DataApiBehavior" name="OAuthServiceProvider.DataApi">
<clear/>
<endpoint address="" binding="wsHttpBinding" contract="OAuthServiceProvider.Code.IDataApi" name="Oauth" bindingConfiguration="wsHttpBinding" />
</service>
</services>
</system.serviceModel>
思考?
お返事ありがとうございました!しかし、消費者とサービスプロバイダーの両方が同じサーバー上にあることを指摘しておきます。実際、同じIIS7サイト内に2つの別個のアプリケーションがあり、プロキシは存在しないと考えられます。私が間違っているなら、私を修正してください。 – Nico
私はHTTPプロキシではなく、wcfプロキシで話していません。消費者のどこかにp = new ProviderService()のようなものがあります。 p.Call()。 p.ClientCredentials.UserNameで認証の詳細を指定する必要があります。ユーザーとパスワード –