我在 VS2010 上运行 SL4。我有一个应用程序通过 Web 服务对我的数据库中的 SPROC 进行身份验证。不幸的是,这不是 WCF/WCF RIA,因为我从我的客户端继承了数据库/服务。
这在浏览器中完美运行(通过 HTTPS)。我正在尝试移动此 OOB,而此时我的身份验证失败。这是我采取的步骤...
1) SL App Properties > Enable running app Out of Browser 2) SL App Properties > Out of Browser Settings > 运行 OOB 时需要提升信任
如果我在登录按钮单击时设置断点,我会看到正在调用服务。但是,如果我单步执行它(或在实际登录 Web 服务上设置断点),代码永远不会走得那么远。这是它失败的块:
public LogonSVC.LogonResponse EndLogon(System.IAsyncResult result) {
object[] _args = new object[0];
LogonSVC.LogonResponse _result = ((LogonSVC.LogonResponse)(base.EndInvoke("Logon", _args, result)));
return _result;
}
我知道使用提升信任意味着不需要 crossdomain.xml。我丢了一个允许一切,只是为了测试,但仍然失败。
这是调用服务的代码:
private void loginButton_Click(object sender, RoutedEventArgs e)
{
string Username = txtUserName.Text;
string Password = txtPassword.Password;
Uri iSilverlightServiceUriRelative = new Uri(App.Current.Host.Source, "../Services/Logon.asmx");
EndpointAddress iSilverlightServiceEndpoint = new EndpointAddress(iSilverlightServiceUriRelative);
BasicHttpBinding iSilverlightServiceBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);// Transport if it's HTTPS://
LogonService = new LogonSVC.LogonSoapClient(iSilverlightServiceBinding, iSilverlightServiceEndpoint);
LogonService.LogonCompleted += new EventHandler<LogonSVC.LogonCompletedEventArgs>(LogonService_LogonCompleted);
LogonService.LogonAsync(Username, Password);
}
我的 LogonService_LogonCompleted 也不会触发(这是有道理的,只是提醒一下)。
我不知道如何解决这个问题,因为这是通过 localhost/IIS 服务的站点运行 OOB。我知道这在浏览器中有效,所以我很好奇什么会破坏它OOB。
更新 根据我阅读的另一篇文章的建议,我将 ServiceReferences.ClientConfig 更改为相对 URL 而不是绝对 URL。这是代码:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="CommonSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
<binding name="LogonSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="/Services/Common.asmx"
binding="basicHttpBinding" bindingConfiguration="CommonSoap"
contract="CommonSVC.CommonSoap" name="CommonSoap" />
<endpoint address="/Services/Logon.asmx"
binding="basicHttpBinding" bindingConfiguration="LogonSoap"
contract="LogonSVC.LogonSoap" name="LogonSoap" />
</client>
</system.serviceModel>
更新 2
堆栈跟踪,如果它可以帮助任何人......
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult 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 TSMVVM.TSMVVMLogonSVC.LogonSoapClient.LogonSoapClientChannel.EndLogon(IAsyncResult result)
at TSMVVM.TSMVVMLogonSVC.LogonSoapClient.TSMVVM.TSMVVMLogonSVC.LogonSoap.EndLogon(IAsyncResult result)
at TSMVVM.TSMVVMLogonSVC.LogonSoapClient.EndLogon(IAsyncResult result)
at TSMVVM.TSMVVMLogonSVC.LogonSoapClient.OnEndLogon(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
谢谢,
斯科特