0
派位图从机器人到WCF服务
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", "application/json");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.connect();
//Create JSONObject
JSONObject jsonParam = new JSONObject();
jsonParam.put("phone", getDiviceID());
jsonParam.put("location", getLocation());
jsonParam.put("image", convertToString(image));
OutputStreamWriter out = new OutputStreamWriter(urlConnection.getOutputStream());
out.write(jsonParam.toString());
out.close();
WCF服务我怎样才能使用的JSONObject
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "sendplantimage",
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
string sendImageToServer(Plants plants);
植物类
[DataContract]
public class Plants
{
[DataMember]
public string phone { get; set; }
[DataMember]
public string location { get; set; }
[DataMember]
public DateTime date { get; set; }
[DataMember]
public string[] plantimage { get; set; }
[DataMember]
public string path { get; set; }
}
我怎么能收集流在实现类,而我路过厂对象在sendImageTOServer(植物植物)和植物中没有数据成员具有数据类型流,因为此处的服务不允许代码
以Base64编码的字符串形式发送图像。一旦到达目的地,您需要对其进行解码。 – Barns
但我如何在服务端获得图像 –
您是否在控制WFC服务? – Barns