Is there is a config setting for tracing WCF calls ? - wcf

I have simple wcf web service that i contain two endpoint connection
soap
rest
I want to have the ability to save the client request and the my server respond on each session as original xml/json.
How to do it ?

Related

Restrict the client connection in WCF service

I have created a WCF service and hosted it in console application. I have 2 client applications which will communicate with that WCF service, now I want to restrict 3 clients to connect to this WCF service.
Is there any way to reject the connection at server side for 3rd client?
Or is there any way server can validate the connection before establishing with
client?
Server side code
Uri httpBaseAddress = new Uri("net.pipe://localhost/ServiceHost/ServiceHost");
studentServiceHost.AddServiceEndpoint(typeof(StudentService.IStudentService), binding, httpBaseAddress);
studentServiceHost.Open()
If you want to stop 3 Clients from Connection to the service at the same time you can use the maxConnections attribute of the binding, setting it to 2.
If you only want specific Clients to Access Your service. Then you need to set up authentication, see: WCF self hosting require authentication

WCF Web Service Client Timeout Values

I am using a WCF web service client to send and receive SOAP messages from a non-WCF web service. I want to control timeouts but really confused by the different timeout settings presented on MSDN.
Is there a simple list of settings for a WCF client (regardless of the server--where I know if server has shorter timeouts they will rule!)? Does it matter by binding or contract (XmlSerizalizer or MessageContact) type?
Have you seen: Timeouts WCF Services? I think that particular question/answer fits what you are looking for.

HTTP Errors while consuming non-WCF Web Service using a WCF Client

I am trying to consume a third party web service, which is developed not in .NET but in some other langauge (may be in Java). I am trying to consume the service from WCF Client. But while adding Service reference it is throwing a error:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'basic realm="EXTRACT-CREDENTIAL"'.
Also when I am hitting the service URL in a browser it's throwing an error as follows:
HTTP GET Requests are not supported by the broker. Please use HTTP POST instead
What could be the way to consume the service from WCF client?

Can I listen to a WCF event from a web client?

Can I listen to a WCF event from a web client? Is this possible? I am not talking about call backs, I want the WCF service to raise and event and the web client to be able to listen. Is there a good example of this in C#?
There are no events in WCF. If you want mimic event you still have to call some operation exposed on all clients = you must call WCF service or callback exposed on client.
What do you mean by web client? Do you mean javascript code running in web browser? In such case no you can't achieve that with WCF. You can only use AJAX calls from borowser and continuously poll the service for possible "event".
If you mean ASP.NET application then the answer is theoretically yes, practiacally it will be pretty hard. The reason is that in ASP.NET you handle only current HTTP request by some handler - for example Page. The lifetime of the handler is only for serving the single request. Due to that using duplex service doesn't make to much sense because for receiving callbacks by duplex service your client proxy must live. If you open the proxy in Page it will die after serving the request. If you open the proxy in separate thread you must somehow corelate incomming callbacks to actual client but the client still have to poll the web server to be notified about callbacks. Similar situation will be with exposing the service on ASP.NET application.
Difference between asynchronnous and duplex calls is big. In asynchronnous pattern single request always have single response. Resonse is not sent without request. In duplex pattern you can make single request and receive thousands callback from server.

Calling WCF Service from MS Access

I want to create a create a WCF Service which is invoked on the button click of MS Access Form.
You CAN consume WCF services through MS Access, but not via standard WCF mechanisms. You'll need to consume the service via GET requests, POST requests, or SOAP requests.
One way to accomplish this for SOAP requests on the Access side is using the SOAP toolkit:
http://msdn.microsoft.com/en-us/library/aa140260%28office.10%29.aspx
Another way that would work for GET, POST or SOAP requests is using XMLHTTP (if you go the SOAP route, you'll need to make your own SOAP envelope in the XML):
http://www.codemaker.co.uk/it/tips/ado_conn.htm (search for XMLHTTP)
On the WCF side you have a couple of choices:
Host a WebHttpBinding service. This gives you options to expose GET and POST endpoints for your services. See http://www.windowsitpro.com/article/net-framework2/exposing-classic-http-endpoints-with-wcf-in-net-3-5.aspx.
Host a BasicHttpBinding service that exposes a SOAP endpoint (this is the default WCF endpoint if you create a new service in Visual Studio). If you go this route, you probably want to set it to use legacy XML serialization and WSDL for compatibility if you go with option 1 on the access end (see http://msdn.microsoft.com/en-us/library/system.servicemodel.xmlserializerformatattribute.aspx).
One other thing to note: If you create a BasicHttpBinding WCF Service with XmlSerializerFormatAttribute, you are basically getting (from a data exchange standpoint) the same thing as if you were to write a legacy asmx service.
You cannot consume a WCF directly with MS Access.
If you own the WCF service, you would have to change it to a web service using HTTP bindings.
If you don't own it, you will have to write your own web service that is basically a wrapper around the WCF.
Then you can consume it as a web service in MS Access.