Can I call the WCF service from a generic application?
I added a link to the service, and the proxy was generated just fine. But when you create NetTcpBinding programmatically and pass this proxy constructor, the service model throws a PlatformNotSupported exception.
Both application launches in the simulator and on the local computer generate the same exception.
An exception of type "System.PlatformNotSupportedException" occurred in System.Private.ServiceModel.dll, but was not processed in the user code.
"this operation is not supported"
EndpointAddress address = new EndpointAddress("net.tcp://test:9000/ServicesHost/PublishService"); NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.None; PublishingService.PublishClient proxy = new PublishingService.PublishClient(binding, address);
Does anyone have an example of a working WCF client in UAP?
EDIT
This is because the service is a duplex service!
Original contract:
[ServiceContract(CallbackContract = typeof(IPublishCallback))] public interface IPublish { }
After removing the CallbackContract attribute, the UAP client can create a connection, so the underlying WCF works. So I think it's better to rephrase the question. Is it possible to create a duplex WCF client in a universal application?
change servicemodel for host
<system.serviceModel> <bindings> <netTcpBinding> <binding name="netTcpPublishService" openTimeout="00:00:10" receiveTimeout="infinite"> <reliableSession inactivityTimeout="24.20:31:23.6470000" enabled="true" /> <security mode="Transport"> <transport clientCredentialType="Windows" /> </security> </binding> </netTcpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="serviceBehaviour"> <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="serviceBehaviour" name="PublishService.Publish"> <endpoint binding="mexHttpBinding" name="mexPublishService" contract="IMetadataExchange" /> <endpoint address="PublishService" binding="netTcpBinding" bindingConfiguration="netTcpPublishService" name="netTcpPublishService" contract="PublishService.IPublish" /> <host> <baseAddresses> <add baseAddress="http://localhost:8004/ServicesHost/PublishService" /> <add baseAddress="net.tcp://localhost:9004/ServicesHost/PublishService" /> </baseAddresses> </host> </service> </services> </system.serviceModel>
source share