我在VS2010上運行SL4。我有一個應用程序,通過Web服務對我的數據庫中的SPROC進行身份驗證。不幸的是,這不是WCF/WCF RIA,因爲我從客戶端繼承了DB /服務。與「遠程服務器返回錯誤:NotFound」的樂趣 - Silverlight4在瀏覽器外
這在瀏覽器內部完美運行(通過HTTPS)。我試圖移動這個OOB,並且此時我的身份驗證失敗。下面是我所採取的步驟......
1)SL應用性能>啓用運行應用程序在瀏覽器 2)SL應用屬性>的脫離瀏覽器設置的>需要運行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;
}
我知道使用Elevated Trust意味着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不火或者(這是有道理的,只是擡起頭)。
我不知道如何擺弄這個,因爲這是通過本地主機/ IIS服務的網站運行OOB。我知道這個工程雖然在瀏覽器,所以我很好奇什麼會打破它的OOB。
UPDATE 我改變了我的ServiceReferences.ClientConfig相對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)
謝謝
斯科特
此錯誤表示服務器上存在問題。像這樣執行診斷:http://stackoverflow.com/questions/4773026/how-to-debug-wcf-service-call-works-in-vs-but-not-in-iis/4783388#4783388並添加有關信息一個真正的錯誤類型。 – vorrtex 2011-02-15 09:30:40
嘿Vorrtex。這似乎是爲WCF。我試着實現它(只需將system.diagnostics添加到我的web.config中,是嗎?)。沒有日誌文件。我沒有使用WCF,我正在使用asmx Web服務。 – 2011-02-15 17:27:43