.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Duplex Contract using WebHttpBinding

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :WCF


I would like to implement a service that supports bidirectional duplex sessions using http. I would also like to avoid SOAP envelopes in the data transfer. I believe I should be using the WebHttpBinding; however, that does not natively support duplex contracts.

I would appreciate any guidance on how to construct a CustomBinding (the binding elements I need, and the order in which they should be stacked) that will give me what I am looking for.


View Complete Post

More Related Resource Links

Duplex contract between web client and server?

Hi, Can duplex contract be implemented between web client and server using http as a transport?   Thanks jagaurg

WCF Duplex Contract GetCallbackChannel problem


My basic set up is as follows:

  • service is set up to have a duplex contract between the client and server.
  • Server can only have one client connected at a time, once a client connects, the server locks to deny new connections.

Every thing works as expected unless a client does not properly disconnect. So to solve this, I have included a timer on the server, to "ping" the client every 2 seconds. If the method throws an exception, the client is not connected anymore, and the server will unlock to allow a new connection.

My problem is that the OperationContext.Current.GetCallbackChannel<T>  method always returns a null reference and throws an exception in my Tick method regardless of whether or not a client is connected because I am using it in a method that was not invoked by the client.

I know my current set up does work because I can call other "duplexed" methods in methods the the client invokes server side, and the OperationContext.Current.GetCallbackChannel works as expected.

So how do I grab the proper channel to talk back to the client in my timer's tick method? Thanks


An endpoint configuration section for contract 'xxx' could not be loaded because more than one end



I'm trying to test calling a webservice, I've found several free ones on http://webserviceshare.com, but none of them work for me.  Some of them give example calling code in C# which I've translated to VB.NET, they're typically just two to four lines, I don't think I've translated them incorrectly.

On that I've tried is US Zip Validator.  I added a Service Reference to http://www.webservicemart.com/uszip.asmx?WSDL, called ZipService.

I then call it like so:

            Dim myZipService As ZipService.USZipSoapClient = New ZipService.USZipSoapClient()
            Dim myCity As String = myZipService.ValidateZip("27707")

I get the following error on the first line of code:

"An endpoint configuration section for contract 'ZipService.USZipSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name."

A page with information on this web service (including C# source code) is at:


Error : Polling duplex in WCF DotNet4.0


We are making sample polling duplex in .net 4.0.

when ever we are  binding this tag in web.config it shows below error.




Warning    1    The element 'bindings' has invalid child element 'pollingDuplexHttpBinding'. List of possible elements expected: 'basicHttpBinding, customBinding, msmqIntegrationBinding, netPeerTcpBinding, netMsmqBinding, netNamedPipeBinding, netTcpBinding, wsFederationHttpBinding, ws2007FederationHttpBinding, wsHttpBinding, ws2007HttpBinding, wsDualHttpBinding, netTcpContextBinding, wsHttpContextBinding, basicHttpContextBinding, mexHttpBinding, mexHttpsBinding, mexNamedPipeBinding, mexTcpBinding, webHttpBinding'.    D:\DuplexTest\TestPollingDuplexWcf\TestPollingDuplexWcf\TestPollingDuplexWcf\Web.config    9    8    TestPollingDuplexWcf

Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap



I created 2 projects in my solution:

  1. Classic asp.net web service (asmx)
  2. Class library project which references service
  3. web site project which references class library project
  4. Windows app project which references service.

Both projects were created in 3.5 framework and in Visual Studio 2008 Beta 2.

I added web service reference to Class library project. When it asked for namespace I typed "CurrencyProxy". Projects build ok, but when I run web app, Class library throws an error: Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I believe it has something to do with app.config in Class library project. Here is part from app.config:

<binding name="CurrencyServiceSoap" closeTimeout=

Contract-First Web Services: Schema-based Development with Windows Communication Foundation


Schema- first contract-first modeling of Web Services gives you the ability to model your contracts with an XML-centric mindset. This process keeps you focused on universally acceptable types and the hierarchical data structures that can be represented in XML.

Christian Weyer, Buddhike de Silva

MSDN Magazine October 2009

Class To Contract: Enrich Your XML Serialization With Schema Providers In The .NET Framework


The Microsoft .NET Framework 1.x provided minimal options for mapping classes to schemas and serializing objects to XML documents, making this sort of mapping quite a challenge. The .NET Framework 2.0 changes all this with Schema providers and the IXmlSerializable interface.

Keith Pijanowski

MSDN Magazine June 2006

Service Station: Techniques for Contract-First Development


In my May 2005 column, I discussed contract-first development and appropriate times to use it (see Service Station: Contract-First Service Development). In this second part, I'm going to focus on some techniques for contract-first development within the ASMX framework.

Aaron Skonnard

MSDN Magazine June 2005

Service Station: Contract-First Service Development


In one of my previous columns on Service Orientation (SO), I introduced the concept of "contract-first" service development (see Service Station: SOA: More Integration, Less Renovation). Over the next two installments of this column, I'm going to cover the topic in depth.

Aaron Skonnard

MSDN Magazine May 2005

WCF Needs? How to Communicate Multiple Contract via Single Service?

why it needs.   i have many business objects how could i serve to my web application via single service.   i have nearly 500 different business objects. how could contract implement into client web applicatoin.    

How do I autenticate requests using header information with webHttpBinding

I'm using ASIHttpRequest API to communicate with my WCF services. The WCF services are set up as webHttpBinding so I can communicate in basic JSON without SOAP. This is the code I'm using to talk with the service and pass along user credentials (iPhone; but just figure it places the username and password in the header like Digest or Basic):   NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/top_secret/"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setUsername:@"username"]; [request setPassword:@"password"];   I'm using a membership provider on the server side to authenticate my users. Is it possible to authenticate each request using the username and password sent in the above code? Please help I've been searching for a solution for a while.

data contract code generation for large/complex schema (HR-XML/OAGIS) - is there an alternative?

Hello, and thank you for reading.I am implementing a Service based on a predefined specification (HR-XML 3.0). As such, I am starting with the schema, and working my way back to code. There are a number of large Schema documents (which import yet more Schema documents) related to my implementation, provided by this specification.I am able to generate code using xsd.exe, by supplying the "main" and "supporting" xsd files as arguments. But there are several issues, and I am wondering if this is the right approach.- there are litterally hundreds of classes - the code file is half a meg in size- duplicate classes (ex. Type, Type1 - which both represent the same type)- there are classes declared as inheriting from a base class, but that base class is not generated/definedI understand that there are limitations to the types of Schema supported by svcutil.exe/xsd.exe when targeting the DataContractSerializer and even XmlSerializer. My question is two-fold:1. Are code generation "issues" fairly common when dealing with larger, modular xsd files? Has anyone had success with generating data contracts from OAGIS or HR-XML schema?2. Given the above issues, are there better approaches to this task, avoiding generating code and working with concrete objects? Does it make better sence to read and compose a SOAP message directly, while sti

Duplex communication and calling clients from outside the hosted service

Hey,   I am currently building an interface between two applications: One that hosts a WCF service and receives external input (e.g. from a sensory system) and another which subscribes to updates sent by the first.   It is quite easy to call back to the client if I create a ServiceHost and provide it with an instance of my service (using ServiceHost.SingletonInstance). However, if I use a PerSession instance mode, how is it possible to call the clients when I receive an updated from the external sensory system?   Thank you for your time!   Cheers, Till

Uploading Large File (40mb) fails... (webhttpbinding) (Azure)

I'm using javascript to upload a file to my WCF service hosted on Azure.  (40 mb file) Here is the snippets from the web.config for the service: <system.serviceModel> <bindings> <webHttpBinding> <binding transferMode="Streamed" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" openTimeout="00:25:00" closeTimeout="00:25:00" sendTimeout="00:25:00" receiveTimeout="00:25:00" name="WebConfiguration"> </binding> </webHttpBinding> </bindings> <behaviors> <endpointBehaviors> <behavior name="RestfulEndpointBehavior"> <webHttp/> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="CPUploadServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpGetUrl=""/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <services> <service name="CPUpload" behaviorConfiguration="CPUploadServiceBehavior"> <endpoint add

separating service level data from business data in servcie contract

Hi I have read that service level data (like requestId, client name etc. required for tracing/auditing) should be separated from business data(required for actual business operation) ie. differencing "Message Header" from "message payload". When we say 'separation", does that mean service level data should not be defined/declared in my contract class. If so how clients will know what header info they have to pass? I can't enforce header info as part of my contract. i think http://blogs.microsoft.co.il/blogs/bursteg/archive/2006/04/23/141.aspx this is based on assumption that clients are aware what they have to pass in header. Regardssinghhome

SvcUtil-generated code or shared interface/data contract assembly?

If you control both service and client is there any benefit in using svcutil.exe to generate client proxies? Or is it better to share interface/data contract assembly between client and service?

Query Correlation faliure using custom Request/Reply Message Contract classes.

Hi,I have a service which is correlated by a Guid query. When I'm using designer created Message Content/Parameters feature for message definition, everithing working lika a charm. But If I define custom [MessageContract] Request/Reply classes (where request class has Guid SvcUID property for correlation), and choose'em as Message Content in the designer with proper CorrelatesOn definition of course, I have got a service exception about correlation query faliure. Have you folks tried to apply your custom [MessageContract] classes for correlated communication?
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend