Cannot connect to my WCF service right out of the box - wcf

I have a service I am trying to consume in a unit test. At this point I'm just trying to instantiate the thing. After suffering the "Could not find default endpoint element that references contract" error for hours and unable to figure it out, I completely deleted out the consumer and started from scratch. All I did was add a service reference to my test project, point it at my service, hit "GO" and that's it. Still doesn't work. I didn't touch a line of code, yet it doesn't work right after I let VS build the thing.
Here is the relevant line in my app.config for the test project:
<client>
<endpoint address="http://mike-laptop/kbs/FFEDI/Service.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEdiService"
contract="ServiceReference2.IEdiService" name="BasicHttpBinding_IEdiService" />
</client>
In my unit test, here is my method:
public void CreateWebServiceInstance()
{
ServiceReference2.EdiServiceClient webService = new ServiceReference2.EdiServiceClient();
string svcAddress = webService.Endpoint.Address.ToString();
Console.WriteLine("Address is: " + svcAddress);
Assert.IsTrue(svcAddress.Equals("http://mike-laptop/kbs/FFEDI/Service.svc")); // test
}
The error I get is:
System.InvalidOperationException:
Could not find default endpoint
element that references contract
'ServiceReference2.IEdiService' in the
ServiceModel client configuration
section. This might be because no
configuration file was found for your
application, or because no endpoint
element matching this contract could
be found in the client element.
Again, I didn't change anything this time. Any ideas?

Is the service hosted in IIS? Can you hit it in a browser? Do you have a <binding name="BasicHttpBinding_IEdiService">... in your config? Did you try passing the binding config name into the constructor?

Seems fine at first sight to me... some ideas to check / ponder / verify:
does your test project's app.config get read at all? E.g. is it being interpreted at all? Is there a TestProject.exe.config in your bin\debug directory? I'm thinking maybe the test runner might be playing some tricks and not reading the config at all.
or what happens if you specify the name of the client endpoint when creating your service client?
ServiceReference2.EdiServiceClient webService =
new ServiceReference2.EdiServiceClient("BasicHttpBinding_IEdiService");
Does that change anything at all?

Related

Error resolving service using Windsor (3.2.0.0) WcfFacility in ASP.NET MVC3

Still finding my way with Castle.Windsor and the WcfFacility, but this ones got my head scratching. I'm want Windsor to inject the WCF client where it sees that dependency in my repository.
I've added a service reference in Visual Studio and added the following into my bootstrapping code:
container.AddFacility<WcfFacility>();
container.Register(
Component.For<IServiceContract>()
.AsWcfClient(
DefaultClientModel.On(
WcfEndpoint.FromConfiguration("MyEndpoint")
)
)
);
My web.config contains a <client> section with a endpoint named accordingly:
<client>
<endpoint address="http://localhost:63988/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceContract"
contract="IServiceContract"
name="MyEndpoint" />
</client>
When I run my app, I get a YSOD:
Could not find endpoint element with name 'service' and contract
'IServiceContract' in
the ServiceModel client configuration section. This might be because
no configuration file was found for your application, or because no
endpoint element matching this name could be found in the client
element.
Pretty self explanatory but why is it looking for an element with name "service", my element is named "MyEndpoint" which I've correctly passed to the FromConfiguration method?
If I update my web.config to change the name attribute from "MyEndpoint" to "service" - the YSOD is gone and my page works!
<client>
<!-- Changing the name attribute to "service" works? -->
<endpoint address="http://localhost:63988/MyService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceContract"
contract="IServiceContract"
name="service" />
</client>
It seems like the facility is ignoring the endpoint name I've given it?
Or (more likely) I'm not registering my service correctly and the facility is using some naming fallback.
EDIT
It seems that my endpoint name attribute has to be "service"! In every test I've tried I always get the same error if the attribute is any other value - is this a bug?
Cheers
OK - I've managed to get past this problem.
I wrote a simple test harness of one MVC and one WCF and used the WcfFacility with no problems - this gave me the confidence that it does work ;o).
I was using an existing codebase and refactoring to use the WcfFacility so I binned my original changes and started again. This time round, I had no problems.
I suspect I must have missed some duplication in the web.config within the <system.serviceModel> elements - although I swear it was OK!
Cheers

Can't get service to pull from (dead letter) queue

I have a queue named log on a remote machine. When I call that queue locally, I specify a custom dead-letter queue by modifying my NetMsmqBinding:
_binding.DeadLetterQueue = DeadLetterQueue.Custom;
_binding.CustomDeadLetterQueue = new Uri(
"net.msmq://localhost/private/Services/Logging/LogDeadLetterService.svc");
This works fine; when I force my message to fail to get to its destination, it appears in this queue.
Now, I have a service hosted in IIS/WAS to read the dead-letter queue. It it hosted in a site called Services, at Services/Logging/LogDeadLetterService.svc. Here's the service in my config:
<service name="Me.Logging.Service.LoggingDeadLetterService">
<endpoint binding="netMsmqBinding"
bindingNamespace="http://me.logging/services/2012/11"
contract="Me.Logging.Service.Shared.Service.Contracts.ILog" />
</service>
And here's my activation:
<add relativeAddress="LogDeadLetterService.svc"
service="Me.Logging.Service.LoggingDeadLetterService" />
My actual service is basically this:
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any, // Pick up any messages, regardless of To address.
InstanceContextMode = InstanceContextMode.Single, // Singleton instance of this class.
ConcurrencyMode = ConcurrencyMode.Multiple, // Multiple callers at a time.
Namespace = "http://me.logging/services/2012/11")]
public class LoggingDeadLetterService : ILog
{
public void LogApplication(ApplicationLog entry)
{
LogToEventLog(entry);
}
}
My queue is transactional and authenticated. I have net.msmq included as enabled protocols both on the Services site and on the Logging application, and I added a net.msmq binding to the Services site. If I have the binding information as appdev.me.com, I get the following error when browsing to http://appdev.me.com/Logging/LogDeadLetterService.svc (appdev.me.com is setup in my HOSTS file):
An error occurred while opening the queue:Access is denied. (-1072824283, 0xc00e0025).
If I have the binding information as localhost, I get the following error:
An error occurred while opening the queue:The queue does not exist or you do not have sufficient permissions to perform the operation. (-1072824317, 0xc00e0003).
No matter which way I have it set up, the service isn't picking up the dead letter, as it's still in the queue and not in my event log.
Now, I realize that both of these reference a permissions issue. However, in the interest of getting the code part of this tested before figuring out the authentication piece, I have given Full Control to everyone I could think of - to include Everyone, Authenticated Users, NETWORK SERVICE, IIS_USERS, ANONYMOUS LOGON, and myself. (The app pool is running as me.)
Any help as to how to get my service to be able to pull from this queue would be phenomenal. Thanks!
EDIT: According to this MSDN blog entry, 0xC00E0003 corresponds to MQ_ERROR_QUEUE_NOT_FOUND, and 0xc00e0025 corresponds to MQ_ERROR_ACCESS_DENIED, so it looks like I want to have the binding information as appdev.me.com. However, that still doesn't resolve the apparent permissions issue occurring.
EDIT2: It works if I host the service in a console app and provide the following endpoint:
<endpoint address="net.msmq://localhost/private/Services/Logging/LogDeadLetterService.svc"
binding="netMsmqBinding"
bindingNamespace="http://me.logging/services/2012/11"
contract="Me.Logging.Service.Shared.Service.Contracts.ILog" />
So what's going on differently in the console app than is going on in IIS? I'm pretty confident, due to EDIT above, that I'm hitting the queue. So why can't I get into it?
EDIT3: Changed Services/Logging/LogDeadLetterService.svc to Logging/LogDeadLetterService.svc per the advice given here, but no change.
//
[Bonus question: Do I need to handle poison messages in my dead letter queue?]
So, three things needed to be changed:
The binding does have to be localhost.
The queue has to be named Logging/LogDeadLetterService.svc to be found - it's the application and the service, not the site, application, and service.
I had something messed up with the application pool - I have no idea what it was, but using a different app pool worked, so I backed out all of my service-related changes and then recreated everything, and it works.
Well, that was a lot of banging my head against my desk for something as simple as "don't mess up your app pool."

WCF Protocol Exception

We are getting some weird behavior from a service we have deployed on a remote system which we are using to access and post data to.
Retrieving information from the service doesn't seem to be an issue. However, whenever we try to execute insert methods on the service we get an System.ServiceModel.ProtocolException. The weird thing is, it will successfully execute approximate 40 records before faulting.
The client is communicating over SSL and TransportWithMessageSecurity is enabled on the wsHttpBinding.
The error message is being generated at the "Set up Secure Session activity":
System.ServiceModel.ProtocolException,
System.ServiceModel, Version=3.0.0.0,
Culture=neutral,
PublicKeyToken=b77a5c561934e089
The content type text/html of the
response message does not match the
content type of the binding
(application/soap+xml; charset=utf-8).
If using a custom encoder, be sure
that the IsContentTypeSupported method
is implemented properly.
We have tried a number of tests all of which consistently fault as soon as we reach a particular number of inserts.
Any suggestions would be appreciated.
I wonder if the trace viewer might shed some light here? No idea what the problem is, I'm afraid...
If a piece of code sends you HTML, then you should probably read it to see what it says.
You probably have reached the configured message size and the WCF infrastructure is truncating the SOAP message, making the serializer (Contract or XML Serializer) to not be able to deserialize the message.
Try increasing the WCF request size see < readerQuotas >
ASP.NET might not be configured properly for .NET 4.0
navigate where .NET 4.0 is installed and try running the following command to reinstall it:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -iru
This could help somebody. My problem was: I have a web site consuming a WCF service.
After deploying the web site, I forgot to deploy the WCF service, too.
After deploying the WCF service, all worked fine.
I ran into the same problem. Finally, I got a solution by adding some code in the web.config file.
I added these under the <basicHttpBinding> tag:
<binding name="xyz">
<security mode= "Transport" />
</binding>

Could not find default endpoint element

I've added a proxy to a webservice to a VS2008/.NET 3.5 solution. When constructing the client .NET throws this error:
Could not find default endpoint element that references contract 'IMySOAPWebService' in the ServiceModel client configuration section. This might be because no configuaration file was found for your application or because no endpoint element matching this contract could be found in the client element.
Searching for this error tells me to use the full namespace in the contract. Here's my app.config with full namespace:
<client>
<endpoint address="http://192.168.100.87:7001/soap/IMySOAPWebService"
binding="basicHttpBinding" bindingConfiguration="IMySOAPWebServicebinding"
contract="Fusion.DataExchange.Workflows.IMySOAPWebService" name="IMySOAPWebServicePort" />
</client>
I'm running XP local (I mention this because a number of Google hits mention win2k3)
The app.config is copied to app.exe.config, so that is also not the problem.
Any clues?
"This error can arise if you are calling the service in a class library and calling the class library from another project."
In this case you will need to include the WS configuration settings into the main projects app.config if its a winapp or web.config if its a web app. This is the way to go even with PRISM and WPF/Silverlight.
I solved this (I think as others may have suggested) by creating the binding and endpoint address instances myself - because I did not want to add new settings to the config files (this is a replacement for some existing library code which is used widely, and previously used an older Web Service Reference etc.), and so I wanted to be able to drop this in without having add new config settings everywhere.
var remoteAddress = new System.ServiceModel.EndpointAddress(_webServiceUrl);
using (var productService = new ProductClient(new System.ServiceModel.BasicHttpBinding(), remoteAddress))
{
//set timeout
productService.Endpoint.Binding.SendTimeout = new TimeSpan(0,0,0,_webServiceTimeout);
//call web service method
productResponse = productService.GetProducts();
}
Edit
If you are using https then you need to use BasicHttpsBinding rather than BasicHttpBinding.
Having tested several options, I finally solved this by using
contract="IMySOAPWebService"
i.e. without the full namespace in the config. For some reason the full name didn't resolve properly
I've had this same issue. It turns out that for a web REFERENCE, you have to supply the URL as the first parameter to the constructor:
new WebService.WebServiceSoapClient("http://myservice.com/moo.aspx");
For a new style web SERVICE REFERENCE, you have to supply a name that refers to an endpoint entry in the configuration:
new WebService.WebServiceSoapClient("WebServiceEndpoint");
With a corresponding entry in Web.config or App.config:
<client>
<endpoint address="http://myservice.com/moo.aspx"
binding="basicHttpBinding"
bindingConfiguration="WebService"
contract="WebService.WebServiceSoap"
name="WebServiceEndpoint" />
</client>
</system.serviceModel>
Pretty damn hard to remove the tunnel vision on "it worked in an older program"...
I had a situation like this, where i had
WCF Service Hosted somewhere
Main Project
Consumer Project of type 'class Library' which has Service reference to a WCF Service
Main project calls methods from consumer project
Now the Consumer project had all the related configuration setting in <system.serviceModel> Tag of my app.config, its was still throwing the same error as the above.
All i did is added the same tag <system.serviceModel> to my main project's app.config file, and finally we were good to go.
The Real problem, as far as in my case was, it was reading the wrong configuration file. Instead of consumer's app.config, it was referring main proj's config. it took me two hours to figure that out.
"This error can arise if you are calling the service in a class library and calling the class library from another project."
"In this case you will need to include the WS configuration settings into the main projects app.config if its a winapp or web.config if its a web app. This is the way to go even with PRISM and WPF/Silverlight."
Yes, but if you can't change main project (Orchard CMS for example), you can keep WCF service config in your project.
You need to create a service helper with client generation method:
public static class ServiceClientHelper
{
public static T GetClient<T>(string moduleName) where T : IClientChannel
{
var channelType = typeof(T);
var contractType = channelType.GetInterfaces().First(i => i.Namespace == channelType.Namespace);
var contractAttribute = contractType.GetCustomAttributes(typeof(ServiceContractAttribute), false).First() as ServiceContractAttribute;
if (contractAttribute == null)
throw new Exception("contractAttribute not configured");
//path to your lib app.config (mark as "Copy Always" in properties)
var configPath = HostingEnvironment.MapPath(String.Format("~/Modules/{0}/bin/{0}.dll.config", moduleName));
var configuration = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap { ExeConfigFilename = configPath }, ConfigurationUserLevel.None);
var serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
if (serviceModelSectionGroup == null)
throw new Exception("serviceModelSectionGroup not configured");
var endpoint = serviceModelSectionGroup.Client.Endpoints.OfType<ChannelEndpointElement>().First(e => e.Contract == contractAttribute.ConfigurationName);
var channelFactory = new ConfigurationChannelFactory<T>(endpoint.Name, configuration, null);
var client = channelFactory.CreateChannel();
return client;
}
}
and use it:
using (var client = ServiceClientHelper.GetClient<IDefaultNameServiceChannel>(yourLibName)) {
... get data from service ...
}
See details in this article.
This one drove me crazy.
I'm using Silverlight 3 Prism (CAB) with WCF
When I call a WCF service in a Prism module, I get the same error:
Could not find default endpoint element that references contract
'IMyService' in the service model client configuaration section. This
might be because no configuaration file was found for your application
or because no end point element matching this contract could be found
in the client element
It turns out that its looking in the Shell's .xap file for a ServiceReferences.ClientConfig file, not in the module's ServiceReferences.ClientConfig file. I added my endpoint and binding to the existing ServiceReferences.ClientConfig file in my Silverlight Shell application (it calls it's own WCF services).
Then I had to rebuild the Shell app to generate the new .xap file for my Web project's ClientBin folder.
Now this line of code finally works:
MyServiceClient myService = new MyServiceClient();
Several responses here hit upon the correct solution when you're facing the mind-numbingly obscure error of referencing the service from a class file: copy service config info into your app.config web.config of your console or windows app. None of those answers seem to show you what to copy though. Let's try and correct that.
Here's what I copied out of my class library's config file, into my console app's config file, in order to get around this crazy error for a service I write called "TranslationServiceOutbound".
You basically want everything inside the system.serviceModel section:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITranslationServiceOutbound" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://MyHostName/TranslationServiceOutbound/TranslationServiceOutbound.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITranslationServiceOutbound"
contract="TranslationService.ITranslationServiceOutbound" name="BasicHttpBinding_ITranslationServiceOutbound" />
</client>
I was getting this error within an ASP.NET application where the WCF service had been added to a class library which is being added to the ASP.NET application as a referenced .dll file in the bin folder. To resolve the error, the config settings in the app.config file within the class library referencing the WCF service needed to be copied into the web.config settings for the ASP.NET site/app.
I had the same problem, but changing the contract namespace didn't work for me. So I tried a .Net 2 style web reference instead of a .Net 3.5 service reference. That worked.
To use a Web reference in Visual Studio 2008, click on 'Add Service Reference', then click 'Advanced' when the dialog box appears. In that you will find an option that will let you use a Web reference instead of a Service reference.
I found (as well as copying to the client UI's App.config as I was using a Class Library interface) I had to prefix the name of the binding with the name of the Service Reference (mine is ServiceReference in the below).
e.g.:
<endpoint address="http://localhost:4000/ServiceName" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISchedulerService"
contract="ServiceReference.ISchedulerService"
name="BasicHttpBinding_ISchedulerService" />
instead of the default generated:
<endpoint address="http://localhost:4000/ServiceName" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISchedulerService"
contract="ISchedulerService"
name="BasicHttpBinding_ISchedulerService" />
Unit testing a non-library application that consumes a service can cause this problem.
The information that others have entered addresses the root cause of this. If you are trying to write automated test cases and the unit you are testing will actually invoke the service interface, you need to add the service reference to the test project. This is a flavor of the application using library type of error. I did not immediately realize this though because my code that consumes the interface is not in a library. However, when the test actually runs it will be running from the test assembly, not the assembly under test.
Adding a service reference to the unit test project resolved my issue.
I have a situation which in the Unit test. I copied the app.config file to the unit test project. So the unit test project also contains endpoint information.
I faced this problem once. It was because i was still developing the interface that uses WCF service. I configured test application and continued development. Then in development, i changed some of the services' namespaces. So i double checked "system.serviceModel -> client -> endpoint -> contract" in web.config to match WCF class. Then problem is solved.
The namespace in your config should reflect the rest of the namespace path after your client's default namespace (as configured in the project properties). Based on your posted answer, my guess is that your client is configured to be in the "Fusion.DataExchange.Workflows" namespace. If you moved the client code to another namespace you would need to update the config to match the remaining namespace path.
This error can arise if you are calling the service in a class library and calling the class library from another project.
I Have a same Problem.I'm Used the WCF Service in class library and calling the class library from windows Application project.but I'm Forget Change <system.serviceModel> In Config File of windows application Project same the <system.serviceModel> of Class Library's app.Config file.
solution: change Configuration of outer project same the class library's wcf configuration.
Hi I've encountered the same problem but the best solution is to let the .NET to configure your client side configuration. What I discover is this when I add a service reference with a query string of http:/namespace/service.svc?wsdl=wsdl0 it does NOT create a configuration endpoints at the client side. But when I remove the ?wsdl-wsdl0 and only use the url http:/namespace/service.svc, it create the endpoint configuration at the client configuration file. for short remoe the " ?WSDL=WSDL0" .
Do not put service client declaration line as class field,
instead of this, create instance at each method that used in.
So problem will be fixed. If you create service client instance as class field, then design time error occurs !
In case if you are using WPF application using PRISM framework then configuration should exist in your start up project (i.e. in the project where your bootstrapper resides.)
There seem to be several ways to create/fix this issue. For me, the CRM product I am using was written in native code and is able to call my .NET dll, but I run into the configuration information needing to be at/above the main application. For me, the CRM application isn't .NET, so I ended up having to put it in my machine.config file (not where I want it). In addition, since my company uses Websense I had a hard time even adding the Service Reference due to a 407 Proxy Authentication Required issue, that to required a modification to the machine.cong.
Proxy solution:
To get the WCF Service Reference to work I had to copy the information from the app.config of my DLL to the main application config (but for me that was machine.config). And I also had to copy the endpoint information to that same file. Once I did that it starting working for me.
Ok. My case was a little diffrent but finally i have found the fix for it:
I have a Console.EXE -> DLL -> Invoking WS1 -> DLL -> Invoking WS2
I have had both the configurations of the service model of WS1, and WS2 in the Console.EXE.config as recommended. - didnt solve the issue.
But it still didn't work, until i have added the WebReference of WS2 to WS1 also and not only to the DLL that actually creating and invoking the proxy of WS2.
If you reference the web service in your class library then you have to copy app.config to your windows application or console application
solution: change Configuration of outer project same the class library's wcf configuration.
Worked for me
I had the same Issue
I was using desktop app and using Global Weather Web service
I deleted the service reference and added the web reference and problem solved
Thanks
Solution for me was to remove the endpoint name from the Endpoint Name attribute in client web.config
this allowed the proxy to use
ChannelFactory<TService> _channelFactory = new ChannelFactory<TService>("");
only took all day to work out.
Also the contract name was wrong once this fix was in place although it had been wrong when the initial error appear.
Double then triple check for contract name strings people !!
attrib: Ian
Allow me to add one more thing to look for. (Tom Haigh's answer already alludes to it, but I want to be explicit)
My web.config file had the following defined:
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
I was already using basicHttpsBinding for one reference, but then I added a new reference which required basicHttpBinding (no s). All I had to do was add that to my protocolMapping as follows:
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
As L.R. correctly points out, this needs to be defined in the right places. For me, that meant one in my Unit Test project's app.config as well as one in the main service project's web.config.
I had this error when I was referencing the Contract in the configuration file element without the global scope operator.
i.e.
<endpoint contract="global::MyNamepsace.IMyContract" .../>
works, but
<endpoint contract="MyNamepsace.IMyContract" .../>
gives the "Could not find default endpoint element that references contract" error.
The assembly containing MyNamepsace.IMyContract is in a different assembly to the main application, so this may explain the need to use the global scope resolution.
When you are adding a service reference
beware of namespace you are typing in:
You should append it to the name of your interface:
<client>
<endpoint address="http://192.168.100.87:7001/soap/IMySOAPWebService"
binding="basicHttpBinding"
contract="MyNamespace.IMySOAPWebService" />
</client>
I got same error and I have tried many things but didn't work, than I noticed that my "contract" was not same at all projects, I changed the contract as would be same for all projects inside solution and than it worked.
This is project A
<client>
<endpoint address="https://xxxxxxxx" binding="basicHttpBinding" bindingConfiguration="basic" contract="ServiceReference.IIntegrationService" name="basic" />
</client>
Project B :
<client>
<endpoint address="xxxxxxxxxxxxx" binding="basicHttpBinding" bindingConfiguration="basic" contract="ServiceReference1.IIntegrationService" name="basic" />
</client>
Finally I changed for both as :
<client>
<endpoint address="https://xxxxxxxxxxx" binding="basicHttpBinding" bindingConfiguration="basic" contract="MyServiceReferrence.IIntegrationService" name="basic" />
</client>
I had the same issue and it was solved only when the host application and the dll that used that endpoint had the same service reference name.

Why cant my Silverlight application load data from sql on live site using WCF?

My silverlight application loads data fromt he SQL fine when I build locally but when I upload it to the live site it will just wait for data to be loaded but show no errors. It worked up until yesterday where I fear I may have changed a setting somewhere and now I cant access the data it seems?
UPDATE 1: it seems to be a problem with the service references. Everytime I update them, it will clear the ServiceReferences.ClientConfig file and then the program wont build.
UPDATE 2: I have tried cleaning and building but still the same problem.
UPDATE 3: Found an error when trying to access the service reference on the live site:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
It sounds like your application is waiting for something, does it time out after 30 seconds? If so, check your SQL connection string.
If there is another tier between Silverlight and SQL (such as a web service), then set up a connection test to make sure that Silverlight is actually reaching SQL...
Did you accidentally replace your live web.config file? If so, try restoring the old web.config as it may have a setting that's not compatable with your server.
Re: Update 1:
Is there an error? If so please paste it. Also please paste the config file in question on pastebin and link to it from here.
Re: Update 3:
The error "This collection already contains an address with scheme http." is caused by not telling a WCF service explicitly what address you wish to bind to when there are many to chosoe from. In this case it looks like IIS is using multiple URLs, for example, consider these fictional addresses:
www.mysite.com
mysite.com
... so the WCF service has no idea which to use unless you tell it.
The solution, to this is to explictly define what URL to use with the following config lines in the web.config (within the system.serviceModel node) of your WCF service.
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.mysite.com/SomeDirectory/MyService" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
Important:
You should update your question title to indicate that WCF is involved in the solution you have created.