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?
Related
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.
I am having a WCF ServiceLibrary which runs successfully on WCF Test Client.
Now I am trying to build a Website to Host this web service. I am using nettcp binding. My web.config file looks like this
<system.web>
<compilation debug="false" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="tcp_Unsecured" portSharingEnabled="true">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="tcpServiceBehavior" name="MarketFeedServiceLibrary.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcp_Unsecured"
name="data" contract="MarketFeedServiceLibrary.IService1" />
<endpoint address="mextcp" binding="mexTcpBinding" name="metadata"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8080/MarketFeedSite/MarketFeedService.svc" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="tcpServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
I am try to view in browser directly from Solution Explorer
But I get error as shown below
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
I have tried all the solutions available on SO, youtube etc but no luck,
I tried:
Under IIS I have enabled http,net.tcp protocols
I have also gone through: How to: Install and Configure WCF Activation Components
N.B. I am a WPF App Developer, hence WCF and ASP.NET Website are new to me.
Thank You.
Edit: Testing Under WCF Client gives following error
Cannot obtain Metadata from net.tcp://localhost:8080/MarketFeedSite/MarketFeedService.svc 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. WS-Metadata Exchange Error URI: net.tcp://localhost:8080/MarketFeedSite/MarketFeedService.svc Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:8080/MarketFeedSite/MarketFeedService.svc'. Could not connect to net.tcp://localhost:8080/MarketFeedSite/MarketFeedService.svc. The connection attempt lasted for a time span of 00:00:01.9968000. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8080. No connection could be made because the target machine actively refused it 127.0.0.1:8080
Hello trying to get my binding to work over internet.
im using wsHttpBinding and trying to get it to work with soap.
i've tried NetTcpBinding and got my functions to show in the wcftestclient over the internet with my public ip and forwared my port to the right computer, but i could not call any functions failing with:
and i dont think soap can be used with NetTcpBinding so i've been trying to make this config work
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service
behaviorConfiguration="VenatoWCF.Behavior"
name="VenatoWCF.WCFService">
<endpoint
address=""
binding="wsHttpBinding"
contract="VenatoWCF.IService"
bindingConfiguration="Binding">
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8734/WCF/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VenatoWCF.Behavior">
<serviceMetadata httpGetEnabled="true" />
<useRequestHeadersForMetadataAddress />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="Binding" >
<security mode="Message">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
this can be consumed by soap but this this config i cant get any respone with soap or wcftestclient.
soap: Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://(My External ip):8734/WCF/?wsdl' : failed to load external entity "http://(My External ip):8734/WCF/?wsdl"
thank you for answers
EDIT1 sorry wrong config file for thoose who where fast enough to see :/
EDIT2
found in my wsdl file that in the bottom i have <soap:address location="https://dendei:8734/WCF/" /> isent that one supposed to be the one soap connects too and need to be "https://(my external ip):8734/WCF/" ???
how can i change this one? in config file? or in my program?
EDIT3
stumbled on this site while searching UseRequestHeadersForMetadataAddressBehavior
and that solved it localy so i could have localhost in my baseaddress <add baseAddress="https://localhost:8734/WCF/"/>
and it worked with soap so i got back the address it tries to connect too
and worked over the net :)
but with UseRequestHeadersForMetadataAddressBehavior you have to use .NET 4.0
You error message says that you use this Url http://(My External ip):8734/WCF/?wsdl to connect to your service with WcfTestClient. But you defined a different Url in you config file. Have a look a your baseAddress. Try this Url http://(My External ip):8734/Venato/mex?wsdl
Alright got it to work if i switched to 4.0 and use UseRequestHeadersForMetadataAddressBehavior instead of trying to access the wsdl file and change the soap:address that points to the local address still dont know how to do that. :)
and the connection problem was in my computer firewall that blocked connection the router accepted the connection and my own computer blocked it xD
will edit my quest with the config that worked for me cheers!
I have been in the process of converting a http application to https and ssl with a self signed certificate.
for some reason i have to go in the browser to localhost:##### to start the service.
Once the service is started, i test it with the following call in the visual studio 2012 comman prompt:
svcutil.exe https://localhost:10201/?wsdl
and it comes back with
Error: Cannot obtain Metadata from https://localhost:10201/?wsdl
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: https://localhost:10201/?wsdl
Metadata contains a reference that cannot be resolved: 'https://localhost:10201/?wsdl'.
Could not establish trust relationship for the SSL/TLS secure channel with authority 'localhost:10201'.
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
The remote certificate is invalid according to the validation procedure.
HTTP GET Error
URI: https://localhost:10201/?wsdl
There was an error downloading 'https://localhost:10201/?wsdl'.
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
The remote certificate is invalid according to the validation procedure.
If you would like more help, type "svcutil /?"
Is this detremental to my sucess with HTTPS?
My config looks as such:
<system.serviceModel>
<!--SERVICES-->
<services>
<service name="DuplexService.DuplexService"
behaviorConfiguration="sb">
<endpoint
address="basic"
binding="customBinding"
bindingConfiguration="customDuplexBinding"
contract="DuplexService.Interface.IDuplexServiceContract">
</endpoint>
<endpoint
address=""
binding="webHttpBinding"
behaviorConfiguration="webHttpEndpointBehavior"
bindingConfiguration="webHttpsBinding"
contract="Interface.IPolicyRetriever">
</endpoint>
<endpoint
address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="https://localhost:10201" />
</baseAddresses>
</host>
</service>
</services>
<!--BEHAVIOURS-->
<behaviors>
<!--Policy-->
<endpointBehaviors>
<!-- For Policy Service -->
<behavior name="webHttpEndpointBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<!--behaviour for all of the enpoints -->
<serviceBehaviors>
<behavior name="sb">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://localhost:10201"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<!-- This will solve a bug that happens if too many items are sent at once from the gateway to the client -->
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling
maxConcurrentCalls="200"
maxConcurrentSessions="200"
maxConcurrentInstances="200" />
</behavior>
</serviceBehaviors>
</behaviors>
<!-- BINDINGS-->
<bindings>
<webHttpBinding>
<binding name="webHttpsBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
<customBinding>
<binding name="customDuplexBinding">
<pollingDuplex duplexMode="MultipleMessagesPerPoll"
maxOutputDelay="00:00:01"
serverPollTimeout="00:01:00"
inactivityTimeout="02:00:00"
maxPendingMessagesPerSession="2147483647"
maxPendingSessions="2147483647" />
<binaryMessageEncoding>
<readerQuotas
maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpsTransport
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="StreamedResponse" />
</binding>
</customBinding>
</bindings>
<!-- Register the binding extension from the SDK. -->
<extensions>
<bindingElementExtensions>
<add name="pollingDuplex"
type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex" />
</bindingElementExtensions>
</extensions>
</system.serviceModel>
How can i get rid of it? and make the metadata work and the GET work?
I can think of 4 ways to deal with this.
Install the self signed cert as a trusted root auth. MMC -> Certificates
Use a browser to navigate to the wsdl (click past the cert error), save it off, and generate off the wsdl directly.
Put the url of the wsdl in your browser and click past the certificate warning so that you can see the actual wsdl
Save the wsdl to your computer. In chrome you can right click, save as.
In Visual Studio
Right click on the project and select "Add Service Reference"
In the Address box, enter the physical path (C:\directory...) of the downloaded wsdl.
Hit Go
Fire up fiddler and tell it to decrypt https which will install a cert and give you an option to ignore remote cert errors. Described here. http://proq.blogspot.com/2012/02/svcutil-and-https.html
Use a cert signed by a trusted root.
I didn't see a svcutil option to ignore cert errors.
I had the same issue. For me I noticed that the https is using another Certificate which was invalid in terms of expiration date. Not sure why it happened. I changed the Https port number and a new self signed cert. WCFtestClinet could connect to the server via HTTPS!
I'm developing a WCF Service with a custom UserNamePasswordValidatorwith a basicHttpBinding. This configuration, however, works only on HTTPS binding. Since Visual Studio 2010's built in web server does not support https, how can I test my custom validator? I keep getting Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http]. error and, if I set the clientCredentialType to none, the error is gone, but the validator does not get called.
Below is my configuration.
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="ServiceErrorHandler" type="company.application.appserver.implementation.ServiceErrorHandlerBehaviorExtensionElement, AppSoftAppServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<bindings>
<basicHttpBinding>
<binding name="SimpleBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="DefaultBehavior" name="company.application.appserver.implementation.AppSoftUpdate">
<endpoint address="udt" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
name="AppSoftUpdate" bindingNamespace="http://company.application/update/2011/04"
contract="company.application.appserver.interfaces.IAppSoftUpdate" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="AppSoftUpdateMex" bindingNamespace="http://company.application/update/2011/04"
contract="IMetadataExchange" />
</service>
<service behaviorConfiguration="DefaultBehavior" name="company.application.appserver.implementation.AppSoftTransaction">
<endpoint address="udt" binding="basicHttpBinding" bindingConfiguration="SimpleBinding"
name="AppSoftTransacao" bindingNamespace="http://company.application/transaction/2011/04"
contract="company.application.appserver.interfaces.IAppSoftTransacao" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="AppSoftTransacaoMex" bindingNamespace="http://company.application/transaction/2011/04"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding"
httpGetBindingConfiguration="" />
<serviceDebug includeExceptionDetailInFaults="true" />
<ServiceErrorHandler />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType=" company.application.appserver.implementation.AppSoftValidacaoLogin, AppSoftAppServer" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Use IIS for this testing.
Open your project properties, go to the Web tab, hit Use local IIS radio button. This manual is valid for VS2010 too: Using Visual Studio 2008 with IIS 7
If IIS is not installed yet, install it first: How to install IIS.
You need to have Windows edition higher than Windows Home.
You will also need to create a self-signed certificate for your web site. This is easy to do in IIS 7: Self-Signed Certificates on IIS 7 – the Easy Way and the Most Effective Way
You cannot test such WCF service in Cassine (built-in web server in VS 2010). You must use local IIS or install VS 2010 SP1 and download IIS Express which is lightweight web server for development (can replace Cassini in VS and supports HTTPS with self signed certificates). IIS Express doesn't need any specific Windows edition and it works on all versions since Windows XP but it provides same features as IIS 7.5.