我已经制作了制作网站的副本以供临时使用。我的 Silverlight 应用程序在端口 81 上提供服务,并尝试通过端口 2443 上的 SSL 访问 WCF 服务。我已通过输入 URL 验证该服务是否可访问:
https://mydomain.com:2443/UtilService.svc
- 我收到“您已创建服务”页面。
但是当我的 SL 应用程序尝试在服务上执行操作时,我在 Web 服务客户端代码的结尾部分遇到了著名的“NotFound”异常:
{System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at UtilServiceClient.UtilServiceClientChannel.EndTryAutoLogon(IAsyncResult result)
at UtilServiceClient.UtilServiceReference.IUtilService.EndTryAutoLogon(IAsyncResult result)
at UtilServiceClient.OnEndTryAutoLogon(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
我已修改 clientaccesspolicy.xml,如下所示:
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*.mydomain.com:81"/>
<domain uri="https://*.mydomain.com:2443"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
其他值得注意的事情:
生产站点在 443 上提供相同的服务,没有任何问题
使用 fiddler,我验证了 CONNECT:2443 在正确的时间出现。
我关闭了 IIS 中的 SSL 要求,并修改了 WCF 配置以删除传输安全性,并修改了 SL 应用以访问端口 81 上的服务 - 并且它有效。
我正在运行 IIS 6。
是否需要一些 ju-ju 才能通过端口 2443 访问该服务?
最佳答案
叹息。它与 Silverlight 无关:问题在于服务端点上的地址过滤过于严格。我将以下内容添加到我的服务类中,并且一切正常:
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
我通过创建该服务的 Windows 客户端发现了这一点,该客户端返回了有关该错误的更多信息。这个故事的寓意是:不要依赖 Silverlight 为您提供全面的信息!
关于wcf - Silverlight:在非标准 SSL 端口上访问 SSL WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1213766/