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?
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 have created a WCF service and hosted it in a windows service. Testing this service with visual studio works fine and I can consume it. Now I have installed the service on a PC (called PC1) and using another PC (called PC2) I wish to be able to discover it and consume it. I imagine that I will have to modify the app.config file to achieve this.
Here is my current app.config, what do I need to modify to get this to work from other networked computers? I'm guessing the base address is a start?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfAVOLibrary.AVOs">
<endpoint address="" binding="wsDualHttpBinding" contract="WcfAVOLibrary.IAVOs">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- 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="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
oh and i'm running .Net 4.5
(if the web service is not implemented, I recommend this link
http://www.codeproject.com/Articles/28693/Deploying-ASP-NET-Websites-on-IIS-7-0)
You should try to modify the web.config in this place:
<baseAddresses>
<add baseAddress="http://192.168.1.2/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
</baseAddresses>
where 192.168.1.2 is your current ip, or localhost works too, it would see like this:
<baseAddresses>
<add baseAddress="http://localhost/Design_Time_Addresses/WcfAVOLibrary/AVOs/" />
</baseAddresses>
At first place, change localhost by pc1 on base address, like
http://pc1:8733/Design_Time_Addresses/WcfAVOLibrary/AVOs/
After it, try to open the base address url from browser on pc2 (yes, never mind that it is win. service - this is your service url and should be accessible). It should be ok, you need not to continue before you get it work.
When it done - review client's config to match service address.
Was facing the same issue. Added inbound rule to open the port 8733 in Windows Firewall. It worked!
In a selfhosting service as described in this MSDN article
there are two servies.
Now I want to call one from the other. One does some database related stuff and the other provides some work. I want to use the database functionality in the other service.
I tried to add a service reference as mentioned here: Stackoverflow with similar question
but I get the message: "There was an error downloading metadata from the address",
so adding a service reference is not possible.
The service on their own both are running and working, as I already use them from client applications.
This is the web.config from the service I want to use.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
And here are parts from the App.config from my selfhosting service
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<!-- omitted lots of blocks -->
<services>
<service name="MyProject.WorkService.GeneralWorkService" behaviorConfiguration="SimpleServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/"/>
</baseAddresses>
</host>
<endpoint address="traceability" binding="basicHttpBinding" name="WorkService" contract="MyProject.Service2.Contracts.IService2"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
<service name="MyProject.DatabaseService.GeneralDatabaseService" behaviorConfiguration="SimpleServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/"/>
</baseAddresses>
</host>
<endpoint address="gateway" binding="basicHttpBinding" name="DatabaseService" contract="MyProject.DatabaseService.Contracts.IDatabaseService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<client>
<endpoint name="Service2EP" address="http://localhost/someWork" binding="basicHttpBinding" contract="MyProject.Service2.IService2">
</endpoint>
<endpoint name="DatabaseServiceEP" address="http://localhost/gateway" binding="basicHttpBinding" contract="MyProject.DatabaseService.IDatabaseService">
</endpoint>
</client>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
-update-
I can use a browser window to see my service on
http://localhost:8000
Perhaps there is some other way to use my service. Should I use some proxy
that can be generated with svcutil?
Perhaps there are better ways. Adding the service reference seems not to work
and I cannot tell why.
Are you sure that you have the mex-endpoint configured in the config of the service you are trying to reference?
If you haven't the service will not expose the info required (WSDL) to make the service reference... .
There are at least 4 possibilities:
The metadata exchange mex endpoint is not defined
Metadata exchange is not enabled
You are using the wrong address
You are being blocked by some security setting
From There was an error downloading metadata from the address
Finally found the answer.
Had to copy the endpoints from the selfhosting app.config into the service web.config.
And from that point on, the error messages in the dialog (link "Details" at the bottom)
were helpful.
Just had to add the service behavior to the DatabaseService that I already have defined in the selfhosting app.config.
Thank you all for all your help. Will accept W1ck3dHcH's answer, as it was right, but I just did not see it.
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!