WCF OperationContract for both duplex and non-duplex endpoints
I am trying to host a WCF service that supports wshttpbinding
and basichttpbinding
.
The reason is for desktop clients I need duplex and for Windows mobile clients I don't.
Lets say I have 3 OperationContracts, 2 of them need duplex and开发者_运维知识库 1 of them does not.
So is it possible to expose 2 OperationContract with wsHttpBinding
and the last one with
just basicHttpBinding
?
Because when I tried I get this error :
Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.
Is there a way to make this work? Or do I have to make separate WCF services for each binding?
Thanks for advice and help.
Every endpoint always exposes all operations for that service that it's representing.
You cannot expose your "basic" endpoint for one method of Service1
, and your duplex endpoint for the two others.
If you need to be able that kind of flexibility, you need to create two separate service implementations - one that handles the duplex operations, one that handles the others.
<endpoint
address="ws"
binding="wsHttpBinding"
contract="YourNamespace.IMyService" />
<endpoint
address="basic"
binding="basicHttpBinding"
contract="YourNamespace.IMyService" />
Now u can access the service from diff clients using ,
http://localhost/ws
http://localhost/basic,
provided, base address is
<host>
<baseAddresses>
<add baseAddress="http://localhost/" />
</baseAddresses>
</host>
If u access using the basic URI, the session will not be created.
精彩评论