Just need to call by using JSON method as below from android
WCF service method Declaration
public class Sub
{
public string HostUID { get; set; }
public string HostName { get; set; }
}
so the rest service method input is as below:
[OperationContract(Name="SampleSUb")]
[WebInvoke(UriTemplate = "/Subsc", Method = "GET",RequestFormat=WebMessageFormat.Json,ResponseFormat=WebMessageFormat.Json))]
public string Method1(Sub input);
Android Java code:
URI uri = new URI("http://.............");
JSONObject jo1 = new JSONObject();
jo1.put("Id", "12");
jo1.put("StringValue", "as");
HttpURLConnection conn = (HttpURLConnection) uri.toURL().openConnection();
conn.setRequestProperty("Content-Type","application/json; charset=utf-8");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("User-Agent", "Pigeon");
conn.setChunkedStreamingMode(0);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.connect();
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
out.write(jo1.toString().getBytes());
out.flush();
int code = conn.getResponseCode();
String message = conn.getResponseMessage();
InputStream in1 = conn.getInputStream();
StringBuffer sb = new StringBuffer();
String reply1;
try { int chr; while ((chr = in1.read()) != -1) { sb.append((char) chr); }
reply1 = sb.toString(); }
finally { in1.close(); }