WCF OperationContract for both duplex and duplex endpoints

I am trying to host a WCF service that supports wshttpbindingand basichttpbinding. The reason is that for desktop clients I need duplex, and for mobile Windows clients I do not.

Suppose I have 3 OperationContracts, 2 of them need duplex, and 1 of them do not.

So, you can expose 2 OperationContract with wshttpbinding, and the latter using just basichttpbinding?

Because when I tried to get this error:

The contract requires a session, but the "BasicHttpBinding" binding does not support or configure it properly to support it.

Is there any way to make this work? Or do I need to make separate WCF services for each binding?

Thanks for the advice and help.

+3
source share
2 answers

Each endpoint always provides all operations for this service that it represents.

You cannot set your “base” endpoint for one method Service1and your duplex endpoint for two others.

If you need such flexibility, you need to create two separate service implementations: one that handles duplex operations, which handles the others.

+2
source
 <endpoint 
         address="ws" 
         binding="wsHttpBinding" 
         contract="YourNamespace.IMyService" />
     <endpoint 
         address="basic" 
         binding="basicHttpBinding"
         contract="YourNamespace.IMyService" />

Now you can access the service from client clients using

http://localhost/ws 
http://localhost/basic,

base address

       <host>
           <baseAddresses>
                <add baseAddress="http://localhost/" />
            </baseAddresses>
       </host>

If you access the base URI, the session will not be created.

0
source

All Articles