【发布时间】:2014-07-21 18:07:06
【问题描述】:
我需要调用cancel方法,但是系统没有调用该方法并且没有报错。
url = new URL("http://localhost/api/Service.svc/Method/cancel");
con = (HttpURLConnection) url.openConnection();
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setRequestProperty("Authorization", "Basic " + Base64.encodeToString("user:password".getBytes(), Base64.NO_WRAP ));
con.setRequestMethod("DELETE");
con.connect();
在我的服务器 C# 中:
[OperationContract]
[WebInvoke(Method = "DELETE", BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/cancel")]
void Cancel();
缺少什么?
更新:
我插入代码con.getResponseCode(),返回值401。这是什么?
【问题讨论】:
-
根本不可能没有错误。在 android 部分发布更多上下文代码,然后再次检查您的 logcat
-
我插入代码
con.getResponseCode(),返回值401,这是什么?
标签: c# android web-services httpurlconnection