我已经创建了一个简单的WCF-服务,我想通过https访问它。WCF使用UserNamePasswordValidator、customBinding和UserNameOverTransport作为身份验证模式.我在IIS7.5中运行它,其中我创建了一个自签名的服务器证书。
我尝试用Silverlight 4应用程序连接到该服务。我在我的Silverlight 4应用程序中创建了一个服务引用,VS 2010自动创建所需的代码(因此很明显,它能够连接到服务并获取信息)。
当我调用WCF时,我会得到一个SecurityException,没有任何关于原因的信息。
我让小提琴手跑过去看看发生了什么。
找不到https://my.server:8099/clientaccesspolicy.xml 404 (text/html) 获取https://my.server:8099/crossdomain.xml 200 OK (文本/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:西西哈伊特-费勒(对象状态) bei System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) bei System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult结果)}
这是我的UserNamePasswordValidator。注意,由于调试原因,其中包括一个记录器。奇怪的是,记录器从来不写任何东西,所以看起来,验证函数甚至没有被调用。
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>我想不出问题的原因是什么。
提前谢谢你,
弗兰克
发布于 2010-11-03 13:12:08
您clientaccesspolicy.xml允许https吗?
这里就是一个例子。
发布于 2010-11-03 14:03:21
Siradeghyan的工作clientaccesspolicy.xml -> Tipp
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="https://*"/>
<domain uri="http://*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>https://stackoverflow.com/questions/4086589
复制相似问题