I’m working on a wcf service to stream a datafile & its relevant information to an android client, I’m however sill a new to WCF, there is just a lot of reading and a lot of the time its not clear which is the best method to follow!
Which Format Should i impose on this service considering it will be an android device calling it ? Consider my code and what would be easily implemented, soap , json, rest or other ?
Any Examples would also be welcome esp one with the code I’ve defined below.
thanks!
[MessageContract]
public class DownlaodStreamItem
{
[MessageHeader]
public Int64 ItemID { set; get; }
[MessageHeader]
public Int64 SizeOfFile { set; get; }
[MessageHeader]
public String Name { set; get; }
[MessageBodyMember]
public Stream Data { set; get; }
}
[MessageContract]
public class someString
{
[MessageBodyMember]
public string SomeString{ set; get; }
}
Service
[OperationContract]
DownlaodStreamItem DownloadMessagecontact(someString SomeString);
Service :IService
public DownlaodStreamItem DownloadMessagecontact(someString SomeString)
{
DownlaodStreamItem DLITEM = new DownlaodStreamItem();
// Populate & return DownlaodStreamItem ....
return DLITEM;
}
For android as client and .NET as service, best way is to write WCF REST Service. Because in this case you do not need to create any proxy class at android end and you can consume it just by making Http request.
You can easily write REST WCF Service using the WCF REST Service Template 40 (CS).
Please refer this on how to write it.
Then you may simply use following code at android to consume this REST service. Hope this will help you.