Answered by:
Silverlight WCF Error communicating with MSSQL

Question
-
I've developed a silverlight app and a webpage which communicated with a WCF service which communicated with a MSSQL Database server 2008. I've hosted the MSSQL Database on my own net, the silverlight app, asp.net site and WCF service has been hosted by another net.
Now I've moved the database to another server, updated the WCF service to point on this new location. The database is now hosted in the same net as the rest. After the moving of the MSSQL database do I get a error when WCF is communicating with the MSSQL database when silverlight is using the WCF Service. However when my asp.net site is using the WCF service is it able to communicate with the MSSQL database just fine. How come? The only thing that have been changed in the WCF service is the adress to the mssql database in the web.config file. May also add that domain policy hasn't been changed.
Error messages: The remote server returned an error: 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 MainNS.PlacesClient.SR2.ServiceClient.ServiceClientChannel.EndgetLocationInfo(IAsyncResult result) at MainNS.PlacesClient.SR2.ServiceClient.MainNS.PlacesClient.SR2.IService.EndgetLocationInfo(IAsyncResult result) at MainNS.PlacesClient.SR2.ServiceClient.OnEndgetLocationInfo(IAsyncResult result) at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}</P> <P>----------------------------</P> <P>System.ServiceModel.CommunicationException was unhandled by user code Message="The remote server returned an error: NotFound." StackTrace: 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 MainNS.PlacesClient.SR2.ServiceClient.ServiceClientChannel.EndgetLocationInfo(IAsyncResult result) at MainNS.PlacesClient.SR2.ServiceClient.MainNS.PlacesClient.SR2.IService.EndgetLocationInfo(IAsyncResult result) at MainNS.PlacesClient.SR2.ServiceClient.OnEndgetLocationInfo(IAsyncResult result) at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result) InnerException: System.Net.WebException Message="The remote server returned an error: NotFound." StackTrace: 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) InnerException: System.Net.WebException Message="The remote server returned an error: NotFound." StackTrace: 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) InnerException:
Thursday, October 1, 2009 3:57 AM
Answers
-
Thanks for the replies and suggestions. It was a procedure in the MSSQL database which hadn't been updated propertly as the DB name change when the DB moves its location.Wednesday, October 7, 2009 2:40 PM
All replies
-
This error is mis-leading. If you use Fiddler then you'll be able to see more detail as to what is happening.
You may also need to create a CrossDomainPolicy.
Thursday, October 1, 2009 4:34 AM -
Already got a crossdomain.xml and ClientAccessPolicy.xml files in WCF which says basicly everyones able to connect.
Been looking at fiddler, and i get a more complete stack trace from it, and the responsecode 500 with it.
Thursday, October 1, 2009 5:28 AM -
POST /Service.svc HTTP/1.1
Accept: */*
Content-Length: 201
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IService/getLocationInfo"
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.21022; MS-RTC LM 8; .NET CLR 3.5.30729; InfoPath.2; .NET CLR 3.0.30729; .NET CLR 1.1.4322; .NET CLR 4.0.20506; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)
Host: service.somedomain.com
Connection: Keep-Alive
Pragma: no-cache
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><getLocationInfo xmlns="http://tempuri.org/"><generatedInfoUrlID>?id</generatedInfoUrlID></getLocationInfo></s:Body></s:Envelope>
HTTP/1.1 500 Internal Server Error
Connection: Keep-Alive
Content-Length: 4801
Date: Wed, 30 Sep 2009 12:26:16 GMT
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="nb-NO">Error converting data type nvarchar to uniqueidentifier.</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>Error converting data type nvarchar to uniqueidentifier.</Message><StackTrace> at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) in C:\Users\Administrator\Documents\Visual Studio 2008\Projects\PlacesClient\WcfService1\SQLHelper.cs:line 604
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteDataset(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) in C:\Users\Administrator\Documents\Visual Studio 2008\Projects\PlacesClient\WcfService1\SQLHelper.cs:line 516
at WebService.Sql.SqlProvider.getLocationInfoByGeneratedUrlID(String urlID) in C:\Users\Administrator\Documents\Visual Studio 2008\Projects\PlacesClient\WcfService1\Sql\SqlProvider.cs:line 21
at WebService.BO.ServiceHandler.getLocationInfoFromDB(String generatedUrlID) in C:\Users\Administrator\Documents\Visual Studio 2008\Projects\PlacesClient\WcfService1\BO\ServiceHandler.cs:line 41
at WebService.Service.getLocationInfo(String generatedInfoUrlID) in C:\Users\Administrator\Documents\Visual Studio 2008\Projects\PlacesClient\WcfService1\Service.svc.cs:line 87
at SyncInvokegetLocationInfo(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.Data.SqlClient.SqlException</Type></ExceptionDetail></detail></s:Fault></s:Body></s:Envelope>
Thursday, October 1, 2009 5:28 AM -
It is complaining of an error:
Error converting data type nvarchar to uniqueidentifier
This might be a good starting point to look into.
Thursday, October 1, 2009 6:06 AM -
Hi Arneb,
Did you update the ServiceReference.ClientConfig? The eaiser way is to use Visual Studio 2008 to update the service reference. For how to call WCF, please take a look at this link.
Best regards,
Jonathan
Wednesday, October 7, 2009 8:40 AM -
Thanks for the replies and suggestions. It was a procedure in the MSSQL database which hadn't been updated propertly as the DB name change when the DB moves its location.Wednesday, October 7, 2009 2:40 PM