How to use BasicHttpBinding without using sessions in WCF? Getting error about session support - wcf

I have a WinForm app which uses WCF to call a WCF service. I am trying to troubleshoot an issue and need to look at the wcf trace file without any encryption. So I have WCF endpoint set to use BasicHttpBinding and my service contract is set for SessionMode = SessionMode.NotAllowed.
However I keep getting an error "Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it".
I don't want to use sessions. Why does it think I want to use sessions?
OR how do I get the messages to go on the wire where I can see objects and their properties in clear text in the trace file?

BasicHttpBinding never uses session. There is something incorrectly configured in your code (or you didn't correctly update service reference). To see messages even if security is enabled use Message logging.

Related

Does WCF Add Service Reference require something configured on the service to generate the app config?

We have an existing wcf service, and I created a new project. I want to use it. I hit add service reference, pop in the URL, press OK, and it adds it as a service reference but there is no config generated.
I also tried svcutil.exe /language:cs /out:GeneratedProxy.cs /config:app.config [url] but no config is generated, only the proxy cs.
I'm using VS 2013 / .NET 4.0
My question is, is this a sign that the SVC itself has some missing data that is required to build the contracts, or is the problem with adding the service reference?
For the record I have tried unchecking the reuse types option which some questions on here have reported as fixing the problem.
Bonus question, do you think if I can't get this working that manually adding some generic default bindings and endpoint code to the web config will work?
First, the reason that why the Adding service reference generates nothing is that the WCF service is rest style service. By default, the proxy-based invocation of rest style WCF services is complex.
https://en.wikipedia.org/wiki/Representational_state_transfer
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/wcf-web-http-programming-model
Calling the WCF rest style service with the client proxy is uncommon. Generally, we construct an Http request by using an HTTP client library to call the service, such as HttpClient, WebClient.
How to fix "ERR_ABORTED 400 (Bad Request)" error with Jquery call to C# WCF service?
Besides, calling the WCF rest style service with the client proxy is feasible. Please refer to my previous link.
WCF: There was no endpoint listening at, that could accept the message
Feel free to let me know if there is anything I can help with.

Developing Wcf Callback service using netTcpBinding

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.

WCF communicating over the internet

I'm a WCF newbie, and I need some help to begin with a project:
I will have a managed application (server) that needs to communicate (messaging system) with several clients over the internet and vice versa.
What is the best approach to achieve this?
using wsDualBinding?
UPDATE
I decided to use the NetTcpBinding mode instead.
It depends on what capabilities your service needs to expose, and what type of clients you need to support. Any of the HTTP-based bindings will work over the internet, its simply a question of the way the data is encoded.
A summary of the built-in bindings and what they support can be found here: http://msdn.microsoft.com/en-us/library/ms731092.aspx
But the most common are:
BasicHttpBinding - This is a basic web service-style binding, usable by any SOAP client.
WebHttpBinding - This allows your service to be used by non-SOAP HTTP clients
WsHttpBinding - This allows your service to use extended service features like transactions and sessions.
WsDualHttpBinding - This is required if your service needs a duplex channel, meaning your service needs to make callbacks up to the client.
Since you specifically asked about the dual binding:
If you are writing an application that needs to be able to make a callback from server into the client, then a dual binding is really your only option. Since you specifically mentioned chat, however, I don't think a dual-channel service is going to work very well.
The way the callbacks work in WCF is that your client makes a call to the service, using a dual channel, and must provide an implementation of the callback interface. The server can use this to make calls to the client for the duration of the service method call; the callback context is per-service-call, so once that call returns, it is no longer valid. In other words, your server cannot just asynchronously "call into" your client, it has to wait for the client to "poll" the server. And if you're going to do that, you don't really need the callback anymore.
Honestly, I don't think I would use WCF for an interactive bi-directional chat application, but I can think of two possible options to do so:
Do the polling client option, using a simple BasicHttpBinding on the server and continuously ask for new messages.
Set your client applications up to self-host a local WCF service, and provide the endpoint information to the server when you log in. This requires your clients to accept incoming connections, which gets messy (but if you can pull it off, I'd go for a NetTcpBinding here.)
WSDualHttpBinding is not a good choice for internet. Callback works great only in local network (intranet) that has no Firewall and NAS restrictions.
See this post for more details:
Connecting over internet to WCF service using wsDualHttpBinding times out
Use WsHttpBinding if you want to set up server to server communications (that should work for WPF).
Use WebHttpBinding if you are planning to use data from Javascript.

WCF: Client config for non-.net-clients

I am developing a wcf service (basicHttpBinding) that should also be consumed by non .net clients (e.g. Java clients). But now I wonder how the client can define his client config file. Or is this file only needed for .net-clients? (I am thinking of configurations like maxReceivedMessageSize or maxItemsInObjectGraph for example).
Each development platform (call it as you want: SOAP stack, Framework, API) has its own way to configure communication. You don't need to bother with it. You just need to expose correct WSDL and client's developer will be responsible for configuring the client application based on his needs.
If you want to extend documentation of your service in WSDL you can use wsdl:documentation. WCF doesn't offer it by default but you can use this technology sample to extend WCF. You can use such documentation for example to describe that service operation can return large amount of data. Another approach to add wsdl:documentation is using WCF Extras.
From the sound of it, the client shouldn't have access to those configuration options. For instance, why should a client to the WCF service be able to specify the maxReceivedMessageSize?
What you probably want to do is define these configuration options on the server-side. If a client makes a call and there is a conflict with one of your options (i.e. the client exceeds maxReceivedMessageSize), you'll want to throw a SoapException back to the client.
If you want to let the client have access to the configuration settings before he or she sends a request, you can always implement a simple web service method that sends back the values.

WCF basichttpbinding netTcpBinding routing

I have created a WCF routing service. This service uses basicHTTPBinding as it is external facing, needs to interoperate and the client can't work with wsHttpBinding. This service receives all incoming method calls and forwards them onto another service. This other service is internal and uses netTcpBinding.
The problem is I am getting the following error:
Addressing Version 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)' does not support adding WS-Addressing headers.
Now, I am not entirely sure, but I am assuming this is something to do with the messages coming in as SOAP 1.1 but the netTcpBinding is using SOAP 1.2 and there is a mismatch? If so, how do I work around this? If not, any ideas what else it could be?
Thanks in advance
The answer is to explicitly copy the message into the right message version and then forward that on. You must also remember to copy the message back to the original version on the way back.