I have a very weird problem with a 3 tiers client/server application with WCF.
First, I have a service windows which host WCF services in basicHttpBinding. This is the server app.config :
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="Business.BSServiceManagement" behaviorConfiguration="myServiceBehave">
<host>
<baseAddresses>
<add baseAddress="http://localhost:35001"/>
</baseAddresses>
</host>
<endpoint address="/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehave">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
This service is deployed on a server in DMZ and I have access from my computer (in firefox, if I put service address with port number)
Secondly, I have a client application made with winforms which consume the service with ChannelFactory.
This is the client app.config :
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://192.168.128.1:35001/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="http://192.168.128.1:35001/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="http://192.168.128.1:35001/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</client>
</system.serviceModel>
</configuration>
When I debug client application, all works perfectly. So I've made a installer project to deploy application on several computers but when I execute exe of application (installed or directly in bin/release), I have an error message like this :
There was no endpoint listening at http://192.168.128.1:35001/Users...
The inner exception says:
Unable to connect to the remote server
I tried adding mex endpoint, change port number, check server and client computer firewall, I don't understand where is the problem.
Thanks for your help.
EDIT 1 :
After several tests I have the same problem in release exe but not in debug exe.
If I execute the debug exe all works fine but the release exe return the error message.
The problem is with your Service.
Make sure that the Service is Started and running.
Once you start the Service, browse URL(eg: localhost:8080/example), just to make sure Service is running fine.
When you add Service Reference to your client Application, it automatically generates endpoints in app.config file.
When you added Installer to client project, make sure that it is builds Successfully.
When you install it, it should work for you.
Related
I have a sweet WinForm application (on my computer) and a SQL Server database (on server X). I'm using SqlConnection and everything works fine.
But not I want to change it and use WCF or other technologies to connect and switch information between my app and database.
I also have one more server to use as application server (Server Y).
I've started using WCF: created project, created installer.
Uploaded it on my Y server and installed it. Service started, also I've added Service Reference to my WinForm app, but the ServiceClient is not working properly.
When I call ServiceClient's method it throws exception:
An exception of type 'System.ServiceModel.EndpointNotFoundException' occurred in mscorlib.dll but was not handled in user code
Additional information: There was no endpoint listening at http://localhost:41272/service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
As I guess my endpoint is blowing things up.
So I want you guys help me how to configure SQL endpoint.
Here is my WCF's web.config:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="SampleSvcBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="SampleSvcBehavior"
name="FMG_WCF.FmgService">
<endpoint name="SampleSvcBasicHttpEndPoint"
address=""
binding="basicHttpBinding" bindingConfiguration=""
contract="FMG_WCF.IFmgService" />
<endpoint name="SampleSvcMexHttpEndPoint"
address="mex"
binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:41272/service" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
This error is not related with SQL endpoint. In facts you do not need endpoints for connecting WCF to database. Here is your answer in another post.
EndpointNotFoundException - 404 - Hosting WCF Service over HTTPS in IIS through Visual Studio
You have two options, if the service has been modified from when you created it you can simply right click on the service reference and configure the service reference. In the popup you can change the Url to point to serverX and you service reference and config file will be automatically updated.
If no changes were made to the service, for example your binding type or security then simply updating the Url in the config file should be enough.
I have two project in my machine. In first application i have created WCF service it works correct only i have tested, hosting in console application after hosting press Ctlr+F5 displaying message Host started # 13-Jan-16 12:28:01 PM...
Where as in second application i am trying to add Add Service reference showing an error....
There was an error downloading 'http://localhost:8035/_vti_bin/ListData.svc/$metadata'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8035
Metadata contains a reference that cannot be resolved: 'http://localhost:8035/'.
There was no endpoint listening at http://localhost:8035/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8035
If the service is defined in the current solution, try building the solution and adding the service reference again.
App.config: host application...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour">
<endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService">
</endpoint>
<endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8035/" />
<add baseAddress="net.tcp://localhost:8032"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
I have created a windows service and added that service reference to my metro application.
I have created a package and installed the package in another system and also the windows service. The application has installed successfully. Now I try to run the application. the below exception is thrown while calling the service
There was no endpoint listening at
"http://localhost/TFSClientWindowsService/TFSCClientWindowsService/
that could accept the message. This is often caused by incorrect
address or SOAP action. InnerException: A connection attempt failed
because the connected party did not properly respond after a period of
time, or established connection failed because connected host failed
to respond at 127.0.0.1:80
Below is my config settings at service level:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="TFSClientWindowsService.TFSCClientWindowsService" behaviorConfiguration="MyBehavior">
<endpoint address="" binding="basicHttpBinding" contract="TFSClientWindowsService.ITFSCClientWindowsService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost/TFSClientWindowsService/TFSCClientWindowsService/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</configuration>
when I install the package and access the service it is functioning correctly in my system. but not when I install it in another system.
If you are developing a WinRT app, you cannot talk to a service running on localhost. See this thread for more discussion... http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/17a542e1-8035-4139-9395-d73e3b222eb6
I have this App.config in my wcf service library:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="addr" value="net.tcp://localhost:22222/AdministrationService/"/>
</appSettings>
<system.serviceModel>
<services>
<service name="Watchman.WcfService.AdministrationService" behaviorConfiguration="MyBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:22222/AdministrationService/"/>
</baseAddresses>
</host>
<endpoint name="Ep1" address="net.tcp://localhost/AdministrationService/" binding="netTcpBinding" bindingConfiguration="DuplexBinding" contract="Watchman.WcfService.Interfaces.IAdministration"/>
<endpoint name="mex" address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceThrottling maxConcurrentSessions="10000"/>
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/AdministrationService/Ep1/wsdl"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="DuplexBinding" sendTimeout="00:00:01">
<reliableSession enabled="true"/>
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
but I got error:
"The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified."
It seems like application doesn't this tcp.net endpoint. Why?
I have this App.config in my wcf service library
You cannot have an app.config in a wcf class library and expect WCF to read settings from it. It doesn't make sense. Config files such as app.config are defined in the final executable application project (such as a Console application, WinForms, WPF, ...). Or if it is a web application you use a web.config. But there is not such thing as app.config for a class library. So you might need to include this WCF configuration in the app/web.config of the application using your class library.
You have specified a base address for net.tcp, so the address on the net.tcp endpoint becomes a relative address. So, effectively the address of the end point becomes net.tcp://localhost:22222/AdministrationService/localhost/AdministrationService/.
Change the address on the endpoint to a relative address and re-generate the proxy class using svcutil.
I just noticed that svcutil generates bad endpoint in wcf client project. There's
<endpoint binding="basicHttpBinding"
bindingConfiguration="DefaultBinding_IAdministration"
contract="IAdministration"
name="DefaultBinding_IAdministration_IAdministration" />"
instead of my net.tcp endpoint.
I also observed that's because of generation of ProxyFile.cs and App.config from
svcutil WcfServiceLibrary.dll
If I generate this files from metadata like:
svcutil net.tcp://localhost:8080/AdministrationService/mex /language:C# /out:ProxyFile.cs /config:App.config
then it works fine (in App config is described correct net.tcp endpoint)
Does anyone knows why cooperation svcutil with *.dll goes wrong?
I've written created a WCF service inside a Windows service, and for some reason I can't figure out, I deployed the service on a bunch of systems (all nearly identical in OS and configuration), and it works on all but one server. The configuration for all deployments is identical except for the service's base address.
When the service is started, I get no exception when I open the ServiceHost, and when using netstat -anp I can see the socket has been opened by the service's process. I've set up Windows firewall logging for dropped packets, but the log file remains empty.
If I try accessing the WCF service from WCF Test Client, I get the following message:
Error: Cannot obtain Metadata from net.tcp://myhostname:9001/SysMonitorAgent
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error
URI: net.tcp://myhostname:9001/SysMonitorAgent
Metadata contains a reference that cannot be resolved: 'net.tcp://myhostname:9001/SysMonitorAgent'.
There was no endpoint listening at net.tcp://myhostname:9001/SysMonitorAgent that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
I've tried WCF logging, but the log file does not even get created.
The config for the service is as follows:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<netTcpBinding>
<binding name="InterfaceServiceNetTcpBinding">
<security mode="None">
<transport clientCredentialType="None" protectionLevel="None" />
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="InterfaceServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="SysMonitor.Agent.Interface.InterfaceService" behaviorConfiguration="InterfaceServiceBehavior">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="InterfaceServiceNetTcpBinding" contract="SysMonitor.Agent.Interface.IInterfaceService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://myhostname:9001/SysMonitorAgent" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
I'm kinda lost, because there is NO indication whatsoever as to why it's not working. Any help would be appreciated.
On the server you are deploying too is something running on port 9100?
It seems like it can not find the service. Have you tried changing the base address?
Typical if you deploy it on serval systems and it doesn't work on one it is configuration of the machine. I would check
.NET Versions
Make sure no Firewalls are set up on this machine preventing the binding
Check the port you are binding is open in this case 9100
Make sure any 3rd party .dll are included in the GAC or folder if needed.
Verify all the .dll and your code is up to date.
I see the error message says "net.tcp://myhostname:9001/SysMonitorAgent "
Did you try to replace it with the machine IP Address rather than using the host name?
In addition to David's points, check that the windows service is running.
Any errors in the Event log?