I have developed a WCF service. Now I want my clients can access to it using sockets. I implemented a TCPListener system on my WCF service, but when I try to instantiate my TCPListener object in a separate thread, I get the following error: An attempt was made to access a Socket in a way that is forbidden by its access permissions.
My WCF service is hosted locally.
Someone to help me please ?
Thanks in advance
You shouldn't let your service implement a socket, communicating is the task of the Binding. You could implement a custom binding which instantiates a TCP channel, some hints here and here. You can also just use the net.tcp Binding, if performance is your goal.
Finally the error you get is pretty clear if you search it on the web: it means you're trying to listen on a port that requires administrative privileges or that is already in use.
Related
I added the service to the WCF Test Client app and I get Service Added Successfully, but I don't see any of the operations available.
This WCF service is already being consumed by several javascript charts, so I should be able to see something here.
What am I doing wrong?
By default, WCFTestclient doesn’t support call the Restful service by using a client proxy. WCF creates the Restful style service with WebHttpbinding. thereby the client proxy class generates nothing thought the service WSDL is available.
Besides, we are capable of making a successful call to the service by using a client proxy. please refer to the below link.
WCF: There was no endpoint listening at, that could accept the message
the above client proxy class is generated by adding service reference.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/accessing-services-using-a-wcf-client
Here is a detailed exposition of WCFTestClient from Microsoft document.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/wcf-test-client-wcftestclient-exe?redirectedfrom=MSDN
Feel free to let me know if there is anything I can help with.
In UWP I can not host service using ServiceHost class as it is not available.
Can anyone provide any alternative to host a service that implements a contract and listens on a specified URL?
My requirement is to host a service with a URL that implements a contract on which my web service will send responses.
I haven't heard a way in UWP which can host a service with a URL. UWP technology can consume app service, but it cannot create a URL. UWP can also consume WCF service, but it seems you cannot make ServiceHost work as expected( can you explain more about this part? If app service can help you achieve your job, I recommend that you can use app service directly instead of webservice).
So finally what I can think about is to handle network communications in background with the help from backgroundtask and related triggers. Please have a look at the following doc:
Network communications in the background
In short, as the doc has mentioned, it's the following:
"Apps use background tasks and two main mechanisms to maintain communications when they are not in the foreground: The socket broker, and control channel triggers. Apps that use sockets for long-term connections can delegate ownership of a socket to a system socket broker when they leave the foreground. The broker then activates the app when traffic arrives on the socket, transfers ownership back to the app, and the app processes the arriving traffic."
There are some samples which may helpful to you but you need to choose the appropriate sample by your own scenario:
SocketActivityStreamSocket sample
ControlChannelTrigger StreamWebSocket sample
ControlChannelTrigger HttpClient sample
I stuck in a problem regarding wcf Callback service.
I am trying to develop WCF Callback service using netTcpBinding, I successfully created this Callback Service using wsDualHttpBinding but when i try to achive same thing using netTcpBinding, I am always stuck in some problem.
sometimes it is "Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it."
or "This protocol does not support netTcpBinding"
so anyone can show me how to configure web.config file and how to overcome this types of error..
Thank you.
Without you supplying the code and config that you are currently using it is difficult to tell what is causing this error.
Maybe take a look at Duplex Messaging and TechNet: Creating a Duplex Service.
I have a WCF service running inside Windows Service and it is located on my local network. What I want is to be able to discover WCF from my Silverlight app on my WP7 (on the same network).
I know there a Discovery feature in WCF, however it requires to UDP, which is not supported on WP7. So are there any other ways to discover local WCF?
I also do not know prior to launching WCF the IP address of the WCF service.
The solution I came up with, is to use Sockets as on WP7 they support multicast.
So set up would like this:
Desktop service - Windows Service hosting WCF and small Socket app
which listens on specific port.
WP7 client - before connecting to WCF
a broadcast would be sent using Sockets to find out an IP address of
the machine which runs WCF, when got a response connect to WCF.
For a WCF Service to be referenced in a WP7 project the WCF Service MUST be a BasicEndpoint
You could provide a basic endpoint that exposes a kind of catalog service. It doesn't have to implement UDDI but it could be a custom protocol to suit your needs and return addresses of web services.
This way you only need to know a single address. Of course you can cache returned addresses and query the catalog service only when you are not able to connect.
My WCF Service is hosted under Windows Service and in case it is not running when client makes a call to its methods, client gets the EndpointNotFoundException with this message:
There was no endpoint listening...
Is there a way I can check if the WCF service is up and running before making calls to the service methods?
Thank you!
Besides just calling it?
You could try pinging it, but that would just tell you that it exists and that its running, not that it's able to accept calls or anything.
UPDATE
To ping the web service you can use the Ping class from System.Net.NetworkInformation.
A solution may be to make a 1st 'dummy' call, if that exception is encountered conclude that it's not running.
You could expose the service contract as WSDL, if possible. If you can reach the WSDL page, then it's running, otherwise it's not.