I have one silverlight application that reads the data from the database(SQL Server) using wcf services without using entity framework, on a click of a button. I deployed on my local system and it works fine. The same i deployed on the server and published it. I opened the page and clicked the button to get the data. But it doesn't display the data, also do not display any error. I am confused as to what could be the issue, on which side.
-
Have you added silverlight enabled WCF service right in the
.web project or you are accessing the service from a different project? – Zafar Jan 28 '15 at 06:10 -
Hi Zafar, i am not accessing the WCF service from the different project. Its in my Silverlight app. Thanks. – Manali Jan 28 '15 at 06:18
-
How you generate the proxy to access the service. Is it by just referring the auto generated proxy or you have some custome proxy generation. Please post the URI used for generating the proxy. If possible post your servicereferences.clientconfig file's content. – Zafar Jan 28 '15 at 06:28
-
– Manali Jan 28 '15 at 07:37 -
Hi Zafar, the above is my servicereferences.clientconfig file and it is referring to auto generated proxy. – Manali Jan 28 '15 at 07:38
-
Change the URL localhost:52731/Service1.svc" as localhost for the server's name u wish to deploy and the port number 52731 with the new servers port number while deploying. Let me know if it works. – Zafar Jan 28 '15 at 07:40
5 Answers
It may caused by database accessing in most of case. So below to steps may be help for you:
- check whether your WCF service is accessible.
- check whether connection string in the configuration of WCF is correct.

- 1
-
Hi.. Thanks for the quick response. Can you please let me now how to check whether WCF services are accessible...? I suppose connection string could not be issue as it works fine with my local system. Also i had tried deploying my app in IIS of my local machine, and it works fine. – Manali Jan 27 '15 at 11:34
-
-
If you want to check the WCF service, there has two ways:
you can run wcftestclient.exe from developer compt window, which is a build-in test tool for visual studio.
if you deployed successfully, you should be able to browse your service through IE, url may like - http://localhost:63370/Service1.svc (here is Microsoft official kb for accessing service - https://msdn.microsoft.com/en-us/library/ms734691(v=vs.110).aspx)

- 1
-
Hi. I just tried to create a very simple wcf application. That is on a click of button i am trying to print "Hello World" on the page. I published the service and as again it works fine on my local system, but same when i try to deploy on server it doesn't. This application is damn simple, no complexities, not database connection, nothing. But still fails to call the service from the server. Checking on services,(Service1.svc -. Right Click -> Browse) works fine, but then why it fails to call through application, i don't know. Its getting rather more confusing now. Totally clueless on this. – Manali Jan 28 '15 at 05:54
You can generate the proxy in code as follows
lets say you auto generated the proxy through adding the service reference.
When you try to access your WCF web methods you need a serviceclient. lets say its SomeProxyClient.
In your dataservice class/anywhere you take a property of type SomeProxyClient
in the getter method of the property try the below code with your WCF service URL
private SomeProxyClient _proxy;
SomeProxyClient Proxy
{
get
{
if (_proxy == null)
{
var binding = new BasicHttpBinding
{
MaxReceivedMessageSize = 2147483647,
MaxBufferSize = 2147483647
};
Uri uri = null;
if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
{
hostName = HtmlPage.Document.DocumentUri.Host;
portNo = HtmlPage.Document.DocumentUri.Port;
uri = new Uri("http://" + hostName + ":" + portNo.ToString() + "/y/x.svc");
}
else
{
uri = new Uri("http://localhost:2700/x.svc");
}
_proxy = new SomeProxyClient(binding, new EndpointAddress(uri));
_proxy.Endpoint.Binding.CloseTimeout = new TimeSpan(01, 20, 10);
_proxy.Endpoint.Binding.ReceiveTimeout = new TimeSpan(01, 20, 10);
_proxy.Endpoint.Binding.SendTimeout = new TimeSpan(01, 20, 10);
_proxy.Endpoint.Binding.OpenTimeout = new TimeSpan(01, 20, 10);
return _proxy;
}
return _proxy;
}
}
Then by using this variable you can access your WCF web methods.
By this way you don't have to touch the service reference all the time i.e from development to production deployment. It will automatically take the respective server and port address.
Hope this helps

- 147
- 14
-
Hi Zafar, i am not very good at this. I understood the reason for writing the manual code for generating proxy and all. But can you also help, as in where exactly should i be writing this code and where should i be calling this from? Also in above code what exactly means "SomeProxyClient"... Your help in this is quiet appreciated. Thanks once again... – Manali Jan 28 '15 at 10:15
It sounds like you IIS cannot handle .svc request.
If this is the case, you may be able to find something here - WCF Service Deployment in IIS Page cannot be displayed and how does the SVC file work?
Actually the issue was on setting up endpoint address in web.config file and also as the services was getting deployed in other machine, the URL of the application was getting changed. So i made some important changes given below: 1. Gave the endpoint address, endpoint name and Contract details in web.config file same as in ServiceRefrence.ClientConfig file. 2. Change the endpoint address in ServiceRefrence.ClientConfig without specific port details :http://Localhost/.....
rather thenhttp://Localhost:56279/.....
and 3. Coded in the app to get the URI address of the machine where it executes so that wherever the app is deployed user has not to worry about the localhost address and its port details: Uri servUri = new Uri("../Service.svc", UriKind.Relative); EndpointAddress servAddr = new EndpointAddress(servUri); ServiceReferenceForSelect.ServiceForSelectClient objSelect = new ServiceForSelectClient("BasicHttpBinding_IService", servAddr);
This solved the problem. Thanks Guys for the help.

- 295
- 3
- 5
- 16