I am just starting to learn WCF. I have successfully set up a WCF service with host console app. The service maps to SQL Server with Entity Framework. I then have a WPF client app which consumes the service. This all works fine in Dev, both the service and client app running from my machine:
<endpoint address="http://localhost:8081/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
name="BasicHttpBinding_IRegimesService" />
I have now transferred the service and host onto my new VM. The service host runs fine. I am now trying to configure the client app endpoint to connect to the service. I think the HTTP address is incorrect:
Service app.config:
<services>
<service name="diiRegimesService.RegimesService">
<endpoint address="" binding="basicHttpBinding" contract="diiRegimesService.IRegimesService"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8082" />
</baseAddresses>
</host>
</service>
</services>
Client app.config:
<client>
<endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
name="BasicHttpBinding_IRegimesService" />
</client>
The server credentials for remote desktop are: emea-myserver01.emea.basketballinfo.com
I currently don't specify a username & password in my client app.config.
The service is running on the server. I'm getting an exception trying to add the service reference in the client app.
Add Service Reference- Adress: http://EMEA-myserver01.emea.basketballinfo.com
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://emea-myserver01.emea.basketballinfo.com/'.
You need to make sure the server is able to resolve the full domain name.
Also, the address url provided in the client configuration snippet <endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/ does not seem valid. Perhaps you want to use <endpoint address="http://emea-myserver01.emea.basketballinfo.com:8082/
After implemeting a WCF service, hosting it on the IIS Server, it returned with the below error.
EndpointNotFoundException was unhandled by user code There was no
endpoint listening at XXXXX that could accept the message. This is
often caused by an incorrect address or SOAP action. See
InnerException, if present, for more details.
That service is identically has the same implementation and configuration of 5 running services with no errors.
when I tried to figure out what is going on the IIS server, the below screenshot.
So it seems that this specific service has no detected Contract. although I'm using the same configuration as below.
<service name="XX.XX.Provisioning.EldaftarManagementService">
<endpoint address="" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" bindingNamespace="http://XX.XX.com/XX/" contract="XX.XX.Provisioning.Eldaftar.IEldaftarManagementService" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="ProvisioningBasicBinding" bindingNamespace="http://XX.XX.com/provisioning/" contract="XX.XX.Provisioning.Eldaftar.IEldaftarManagementService" />
</service>
<service name="XX.XX.Provisioning.Common.UserManagement.UserManagementService">
<endpoint address="" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" bindingNamespace="http://XX.XX.com/XX/" contract="XX.XX.Provisioning.Common.UserManagement.IUserManagementService" />
<endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="ProvisioningBasicBinding" bindingNamespace="http://XX.XX.com/provisioning/" contract="XX.XX.Provisioning.Common.UserManagement.IUserManagementService" />
</service>
Kindly noted that when accessing the service.svc url it replies normally and the wsdl is shown. So that means it's hosted fine on the IIS.
Do I miss something?
Update:
Client config.
<endpoint address="https://XXX/EldaftarManagementService.svc" behaviorConfiguration="ProvisioningClientBehaviour" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" contract="EldaftarManagementService.IEldaftarManagementService" />
<endpoint address="https://XXX/UserManagement.svc" behaviorConfiguration="ProvisioningClientBehaviour" binding="customBinding" bindingConfiguration="ProvisioningServiceBinding" contract="UserManagementService.IUserManagementService" />
i notice sometime after reconfigure my service reference, the client config getting wsdl with server name. then i get EndpointNotFoundException exception.
example :
service reference is : http://192.168.61.2:1111/Service1.svc
but in the config endpoint address it show : http://serverName:1111/Service1.svc
After i change the config endpoint address with the service reference address , then it resolved. Not sure why but now every time when i reconfigure the endpoint address, i will manually change the config endpoint address to make sure it get the same address.
I am just learning wcf and I tried creating a WCF service but I keep getting this exception:
Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no
endpoint listening at http://localhost:8733/Person/ that could accept the messa
ge. This is often caused by an incorrect address or SOAP action. See InnerExcept
ion, if present, for more details. ---> System.Net.WebException: Unable to conne
ct to the remote server ---> System.Net.Sockets.SocketException: No connection c
ould be made because the target machine actively refused it 127.0.0.1:8733
I started out by creating a WCF Service Library.I have defined my service contract and data Contract here.And configured the endpoint witch look like this:
<service name="SelfHosting.PersonContract">
<endpoint address="" binding="basicHttpBinding" contract="SelfHosting.IPersonContract">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Person/" />
</baseAddresses>
</host>
</service>
These two endpoints were already added I just configured them to my needs.I am not sure what the mex endpoint is used for so I am hopping someone can tell me.
I then created a console application and I added a reference to the service.I have initialized an instance of the service and then I tryed calling it:
static PersonContractClient client = new PersonContractClient();
static void Main(string[] args)
{
var persons = client.GetPersons();
foreach (var personData in persons)
{
Console.WriteLine(personData.Name);
Console.WriteLine(personData.Email);
}
}
I have not set any endpoints on the client because from what I know they are automaticly added when you add a reference to the service.This was added after I adde the reference:
<endpoint address="http://localhost:8733/Person/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IPersonContract" contract="PersonNamespace.IPersonContract"
name="BasicHttpBinding_IPersonContract" />
My solution also contains another project that has the data, which I get using Entity Framework. I do not know if this is relevant to the problem.
What am I doing wrong here?
I had similar problem when i tried to create a duplex wcf communication using self host in a console application. Following this example http://adamprescott.net/2012/08/15/a-simple-wcf-service-callback-example/ made it clear. It is common to get the error
"Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://localhost:8733/Person/ that could accept the messa ge. This is often caused by an incorrect address or SOAP action. See InnerExcept ion, if present, for more details. ---> System.Net.WebException: Unable to conne ct to the remote server ---> System.Net.Sockets.SocketException: No connection c ould be made because the target machine actively refused it 127.0.0.1:8733"
Before attempting to discover the service reference in the client console app, you need to start up the executable(.exe) of the service by right click the .exe in the folder location > copy the uri in the baseaddress in the service app.config and paste in the add service reference dialog then click ok... that fixed it. I hope this helps others, since the question is a bit old.
Instead of 'localhost' in the url use the ip address of the endpoint.
I have moved my file transfer service from basicHttpBinding to netTcpBinding
as I am trying to set up a duplex mode channel. I have also started my net.tcp
port sharing service.
I am currently in dev and am self hosting on an xp box until we move the
app to a dev server. so, for now, I do not have access to IIS.
After configuring my service as such:
<service behaviorConfiguration="transferServiceBehavior" name="API.FileTransfer.FileTransferService">
<endpoint name="MyFileTransferEP"
address = ""
binding = "netTcpBinding"
bindingConfiguration="MyFileTransferNetTcpEP"
behaviorConfiguration="NetTcpEPBehavior"
contract="API.FileTransfer.IFileTransferService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001/project/filetransfer.svc" />
</baseAddresses>
</host>
</service>
And, my binding as such:
<netTcpBinding>
<binding name="MyFileTransferNetTcpEP"
hostNameComparisonMode="StrongWildcard"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
maxReceivedMessageSize="2147483647"
transferMode="Streamed"
portSharingEnabled="true">
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="None" />
</security>
</binding>
</netTcpBinding>
I get the folloing error when I right and browser to the SVC file:
Could not find a base address that
matches scheme net.tcp for the
endpoint with binding NetTcpBinding.
Registered base address schemes are
[http].
The reading online suggests that, in order to fix this problem, i
needed to add the net.tcp binding to the binding of the application
in IIS. But, what do I do if I am self hosting and do not have access to
IIS?? By the way, if you are reading this and "do" have IIS, do the following:
Right click the virtual directory/application in IIS -> Manage application ->
Advanced settings. And, in the Enabled Protocols part, add net.tcp.
Any ideas?
UPDATE: I thought I had it working but it's still not working. Here is what I have now:
I am still getting the "could not find base address that matches scheme net.tcp" error.
I have changed all my base addresses to reflect your suggestion. Here is what I have now:
<service behaviorConfiguration="transferServiceBehavior" name="API.FileTransfer.FileTransferService">
<endpoint name="MyJSONFileTransferEP"
address="json"
binding="webHttpBinding"
bindingConfiguration="jsonWeb"
behaviorConfiguration="WebHttpEPBehavior"
contract="API.FileTransfer.IJSONFileTransferService" />
<endpoint name="MyPOXFileTransferEP"
address="pox"
behaviorConfiguration="WebHttpEPBehavior"
binding="webHttpBinding"
bindingConfiguration="poxWeb"
contract="API.FileTransfer.IPOXFileTransferService" />
<endpoint name="MySOAPFileTransferEP"
address="filetransfer"
binding="netTcpBinding"
bindingConfiguration="netTcpWeb"
behaviorConfiguration="NetTcpEPBehavior"
contract="API.FileTransfer.ISOAPFileTransferService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:2544/filetransfer/" />
</baseAddresses>
</host>
</service>
I have tried this with both "net.tcp://localhost:2544" & "net.tcp://localhost:8001".
Do I need to add (allow) something in my firewall settings? Any other suggestions?
Here is my filetransferservice's mexTcpBinding in my App.config file:
<endpoint address="net.tcp://localhost:2544/filetransfer/mex"
binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange"
name="filetransfermex">
<identity>
<certificateReference storeName="My" storeLocation="LocalMachine"
x509FindType="FindBySubjectDistinguishedName" />
</identity>
</endpoint>
I am still unable to reference my FileTransferServiceClient in my web app.
Thanks again.
Error (WCF):
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
Step 1:
Note WAS (Windows Process Activation Service) or non-http protocol support, is only supported by following platforms:
• Windows Vista
• Windows 7
• Windows Server 2008
Go to Turn Windows features on or off
Go to Microsoft .NET Framework 3.5
Check Windows Communication Foundation HTTP Activation
Check Windows Communication Foundation Non-HTTP Activation
Step 2:
IIS > WCF Host Web Site > Manage Application > advanced Settings > Enabled Protocols > Set the value to HTTP,NET.TCP
You need to define just the base address (not the whole address) for your service, and then the rest in the service endpoint. The address you have with the filetransfer.svc file at the end is not a valid base address (it's a file address, really)
<service behaviorConfiguration="transferServiceBehavior"
name="API.FileTransfer.FileTransferService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001/project/" />
</baseAddresses>
</host>
<endpoint name="MyFileTransferEP"
address = "filetransfer"
binding = "netTcpBinding"
bindingConfiguration="MyFileTransferNetTcpEP"
behaviorConfiguration="NetTcpEPBehavior"
contract="API.FileTransfer.IFileTransferService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
With this, and using self-hosting, your service would be available at the complete address:
net.tcp://localhost:8001/project/filetransfer
Since this is net.tcp and you're self-hosting, there's no need for a svc file at all.
UPDATE: if you want to be able to get metadata on your net.TCP base address, you'll need to expose a net.Tcp MEX endpoint like this inside your <service> section:
<endpoint name="NetTcpMEX"
address="netTcpMex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
Space in "Enabled Protocols" entry in IIS => Select virtual Directory/application => advanced settings => Enabled Protocols. e.g. http, net.tcp. (Space between protocol text
This should be http,net.tcp (ie. no space between the protocol text)
After going through a lots of solution .. i found the final solution in this blog.. however i am going to explain the whole procedure here .. you need to follow the below steps ..
Step1:
(Windows Process Activation Service) or non-http protocol support, is only supported by following platforms: • Windows Vista • Windows 7 • Windows Server 2008
Go to Turn Windows features on or off
Go to Microsoft .NET Framework 3.5
Check Windows Communication Foundation HTTP Activation
Check Windows Communication Foundation Non-HTTP Activation
Step 2:
IIS > WCF Host Web Site > Manage Application > advanced Settings > Enabled Protocols > Set the value to http,net.tcp
check if your problem solved after step2 completion..if not then follow below step
Step 3:
In an administrator-level Command Prompt window, run the following command.
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='8082:*']
Restart the IIS once or you could get Failed to map the path '/' exception now
Your application in advance setting will looks like below now
For future readers.
Make sure you not using IIS-Express.
This was my "gotcha".
Reference:
http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-express-faq
Q: Does IIS Express support non-HTTP protocols such as net.tcp or MSMQ?
A: No. IIS Express only supports HTTP and HTTPS as its protocol.
This is a property under Visual Studio and the web.csproj (or similar) Properties and the "Web" left-tab. There is a checkbox called "Use IIS Express". Uncheck that.
After you do that, you'll still have to go to IIS(7) and "http,net.tcp" for "Enabled Protocols" (as described in other answers here)
Also, if you're getting the named pipe specific error.
Could not find a base address that matches scheme net.pipe for the endpoint with binding NetNamedPipeBinding.
Then you need to add "net.pipe" to the list.
Example:
http,net.tcp,net.pipe
Also see the below for the named pipe specific error.
Configure WCF as Named Pipe hosted on IIS7
ALSO: Check these corresponding windows services (named pipes or tcp or both)
(named pipes windows service)
NetPipeActivator
Net.Pipe Listener Adapter
Receives activation requests over the net.pipe protocol and passes them to the Windows Process Activation Service.
(tcp windows service)
NetTcpActivator
Net.Tcp Listener Adapter
Receives activation requests over the net.tcp protocol and passes them to the Windows Process Activation Service.
Please install "Non-Http activation" window component from Control Panel -> Programs -> Turn Window On or off -> Features -> Add features -> .net framework .* features -> Wcf activation -> Non-Http Activation.
For Windows 10
Step 1: Go to Turn Windows features on and off > .Net Framework 4.6 Advanced Services > WCF Services > TCP Activation
Step 2: IIS > WCF Host Web Site > Manage Application > advanced Settings > Enabled Protocols > Set the value to net.tcp,http
Step 3: Open command console with administrative rights > type iisreset
I had the same problem (Environment: Win7/IIS7.5 .NET4) and I solved it by configuring the binding through appcmd.exe, available form the directory "c:\Windows\System32\inetsrv"
"appcmd.exe set pp "WebsiteName/applicationName" /enabledProtocols:http,net.tcp"
note: IIS configuration is hierarchical and consequently we should change config at the lowest possible level to avoid unwanted changes/security issues on other applications.
The following links may help:
http://msdn.microsoft.com/en-us/library/ms788757.aspx
http://support.microsoft.com/kb/2803161
Hope this help
Albert
I had the same error on a Windows 7 and fixed it by opening IIS, right click on the website that holds your application and select 'Edit Bindings...'. I added here the net.tcp binding and the problem was solved.
Site Bindings PrintScreen
<add baseAddress="net.tcp://localhost:8090" />
Please Edit it in the Config file as Shown
I have been trying to add a new endpoint in a service hosted under IIS but haven't been able to figure it out for the past day or so.
This is my understanding:
you can have multiple endpoints under IIS as long as they have unique addresses.
you could assign a base address but it will be overridden by the virtual directory setup in IIS.
My virtual directory is http://localhost/WcfCert/
<services>
<service name="WcfCertServer.Service1" behaviorConfiguration="WcfCertServer.Service1Behavior">
<endpoint address="" binding="wsHttpBinding" contract="WcfCertServer.IService1"/>
<endpoint address="test" binding="wsHttpBinding" contract="WcfCertServer.IService1"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
I can bring up the service using http://localhost/wcfcert/service1.svc
but http://localhost/wcfcert/test/service1.svc/test doesn't return anything in IE or the client app
what am I missing here?
Edit:
So i did further testing, and here is what i discovered.
if i start WcfTestClient.exe and add either http://localhost:1523/Service1.svc or http://localhost:1523/Service1.svc/mex it will add both the endpoint under that address. so here is my question shouldn't http://localhost:1523/Service1.svc only represent the first endpoint? why adding that address bring up both endpoints?
but if I try to add http://localhost:1523/Service1.svc/test I get
Error: Cannot obtain Metadata from http://localhost:1523/Service1.svc/test 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: http://localhost:1523/Service1.svc/test Metadata contains a reference that cannot be resolved: 'http://localhost:1523/Service1.svc/test'. Sendera:BadContextTokenThe message could not be processed. This is most likely because the action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.HTTP GET Error URI: http://localhost:1523/Service1.svc/test There was an error downloading 'http://localhost:1523/Service1.svc/test'. The request failed with HTTP status 400: Bad Request.
It would actually be:
http://localhost/wcfcert/service1.svc/test
If you want the URL to be 'http://localhost/wcfcert/test/service1.svc', then you will need to specify the full URL in the address attribute.
I ran into a similar problem recently, and I believe the reason is because the WcfTestClient requires the mex endpoint to query the metadata for the service it is testing.
When you add the service address "http://localhost:1523/Service1.svc" to the WcfTestClient, it actually queries the endpoint "http://localhost:1523/Service1.svc/mex" to get the service description.
The error "Cannot obtain Metadata from "http://localhost:1523/Service1.svc/test" is displayed because the WcfTestClient is looking for the "/test/mex" endpoint to get the metadata for the service at "/test".
To fix this, you need to add another endpoint to provide metadata about the service hosted at address "/test":
<endpoint address="/test/mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
This is the solution that worked for me.