https経由でアクセスできるようにする簡単なWCFサービスを作成しました。WCFサービスは、認証モードとしてUserNamePasswordValidator、customBinding、およびUserNameOverTransportを使用します。自己署名サーバー証明書を作成したIIS7.5で実行します。
Silverlight4アプリケーションを使用してそのサービスに接続しようとしています。Silverlight 4アプリでサービス参照を作成すると、VS 2010が必要なコードを自動的に作成します(したがって、明らかにサービスに接続して情報を取得できます)。
WCFを呼び出すと、理由に関する情報がないSecurityExceptionが発生します。
何が起こっているのかを見るためにフィドラーを走らせています。
GET https://my.server:8099/clientaccesspolicy.xml 404 Not Found(text / html)
GET https://my.server:8099/crossdomain.xml 200 OK(text / xml)
したがって、crossdomain.xmlのGETは、サーバーへの最後の呼び出しのようです。
crossdomain.xmlは次のようになります。
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*" />
</cross-domain-policy>
例外は、base.EndInvoke(...)がクライアントで呼び出され、ExceptionMessageが次の場合に発生します。
{System.Security.SecurityException ---> System.Security.SecurityException:Sicherheitsfehler bei System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)beiSystem.Net.Browser.BrowserHttpWebRequest。<>c_ DisplayClass5.b _4(Object sendState )beiSystem.Net.Browser.AsyncHelper。<>c_ DisplayClass2.b _0(Object sendState)---EndederinternenAusnahmestapelüberwachung---beiSystem.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod、Object state)bei System .Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)bei System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}
これが私のUserNamePasswordValidatorです。デバッグ上の理由から、ロガーが含まれていることに注意してください。奇妙なことに、ロガーは何も書き込まないので、Validate関数も呼び出されていないようです。
namespace ServiceConfiguratorDataSource
{
public class UserCredentialsValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (userName != "xyz" || password != "xyz")
{
logging.Logger.instance.StatusRoutine("LogOn Error: " + userName);
throw new FaultException("Credentials are invalid");
}
else
{
logging.Logger.instance.StatusRoutine("LogOn Success: " + userName);
}
}
}
}
これが私のWCFサービスのWeb.configです。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="ServiceConfiguratorDataSource.Service" behaviorConfiguration="ServiceConfiguratorDataSourceBehaviour">
<endpoint address="" binding="customBinding" bindingConfiguration="ServiceConfiguratorCustomBinding" contract="ServiceConfiguratorDataSource.IService" />
</service>
</services>
<bindings>
<customBinding>
<binding name="ServiceConfiguratorCustomBinding">
<security authenticationMode="UserNameOverTransport"></security>
<binaryMessageEncoding></binaryMessageEncoding>
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceConfiguratorDataSourceBehaviour">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ServiceConfiguratorDataSource.UserCredentialsValidator,ServiceConfiguratorDataSource" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
そしてここでServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IService">
<security authenticationMode="UserNameOverTransport" includeTimestamp="true">
<secureConversationBootstrap />
</security>
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://my.server:8099/ServiceConfiguratorDataSource/Service.svc" binding="customBinding" bindingConfiguration="CustomBinding_IService" contract="WCFDataProvider.IService" name="CustomBinding_IService" />
</client>
</system.serviceModel>
</configuration>
私は問題の原因が何であるかについての考えがありません。
よろしくお願いします、
フランク