How do I go about making sure that my WCF service can be accessed from any other language(Java, PHP, whatever iOS uses, etc.)?
I have kept everything as httpbinding plus not used any of the .net roles/membership authentication for the clients. But there are some things that I am not sure of. Like, can I return a generic List that is readable by those other languages?
Any of the WCF bindings that don’t start with
net(netTcp, netMsmq etc.) should be fine – they’re designed to be interoperable.The most basic one is
basicHttpBindingwhich is pretty much plain HTTP – nothing much can be added to it. You should be able to call this from any scripting language (PHP etc.).The more advanced binding is
wsHttpBindingwhich implements lots of the WS-* standards and can be called from other languages where the networking stack can handle WS-* – stuff like Java etc.And then there’s the
webHttpBindingwhich exposes your service not via SOAP, but via a REST endpoint. This should be callable from just about any language, any device, any place.And of course, you get the best coverage if you expose multiple endpoints from your service, offering a variety of choices to anyone trying to call you. All this is done simply in config – no code change necessary to support multiple endpoints, multiple bindings etc.
As for lists and stuff: WCF exchanges serialized messages – basically XML – which is governed by a XML schema. The combination of a WSDL and XSD is totally interoperable and can be understood by a wide variety of other languages.
A
List<T>in .NET will be turned into an array in your XML structure, and that’s totally interoperable – don’t worry. The client might just get back an array instead of a list – but that’s not a problem.The only problem is that you cannot really model a generic list, since the XML schema doesn’t support generics – you need to be explicit about what it is you’re sending back. A
List<T>won’t work – aList<Customer>will (if yourCustomerobject is part of your data contract and marked as such)