1

I currently have a client/server application which is based on Windows technology (using C# .net). I use WCF with transport and message credentials. (i.e. SSL with basic username/password message authentication)

One of the projects about to come up, is to allow the client side to run on an Android platform (phone or tablet).

Are there Android/Java/Linux libraries available to consume a WCF service from within Android code ?

If not, I guess I'll have to write a wrapper around the services and use an alternative method.

Rich S
  • 3,248
  • 3
  • 28
  • 49
  • Possible duplicate of http://stackoverflow.com/questions/669764/how-to-consume-wcf-service-with-android – skynet Nov 14 '11 at 01:14
  • 1
    For what it's worth, I think the answer might have changed a little since then. – Andrew Nov 14 '11 at 01:15

2 Answers2

1

You can also create a JSON binding for your WCF service - that is expose your WCF service as both a WCF service and a JSON service - then use the standard Android webservice method - which is kind of hokey. The advantage of this approach is that you don't have to distribute KSoap - and you are writing less code for the android. JSON is also uses less band width (if that is an issue)

Neil
  • 1,605
  • 10
  • 15
0

WCF basically exposes a SOAP service (provided the binding is set up that way). A fairly current-looking Android library can be found at http://code.google.com/p/ksoap2-android/.

There is some setup you need to do on the WCF side, though. First off, do not use Message security. Use Transport security only. Transport allows you to use HTTPS, which is what you are wanting. Message security in my experience only works between Windows clients, does not allow SSL (it encrypts the message itself so it can go over an unencrypted channel), and seems not to work with other types of clients. If I recall, you want to use some variation of BasicHttpBinding rather than WSHttpBinding, but I don't have a project in front of me at the moment to double-check.

Andrew
  • 14,325
  • 4
  • 43
  • 64
  • thanks for your comment. I'm not sure that I can do without Message Security though, as I need to authenticate the user for each call, as some users have the ability to make some calls, but not others. I guess I could pass the username/password as parameters into each method, it just means quite a few changes to my existing Windows client/server, which I'd want to avoid. – Rich S Nov 14 '11 at 01:28
  • The one time I've dealt with writing a WCF service for a non-Windows consumer (PHP in that case), we ended up passing back a GUID token on login that got sent back with each subsequent request. I know what you mean about it being a pain, though, if you are having to rework an existing service, and perhaps someone has a better solution. – Andrew Nov 14 '11 at 02:27
  • One more thought -- there is something called [TransportWithMessageSecurity](http://msdn.microsoft.com/en-us/library/ff648863.aspx#TransferSecurityModes) that sounds like it somewhat does what you want, but I'm not sure, and I've never used it. – Andrew Nov 14 '11 at 02:38
  • Hi Andrew, I'm currently using TransportWithMessageCredential withing my windows configuration. But I want to replicate this on Android. – Rich S May 22 '12 at 18:14