标签: http-post

IIS 7.5, Web Service and HTTP 405 error

I have a web service which I host on my machine. I use Windows 7 and IIS 7.5.

Problem: When the client tries to consume the web service, he/she gets a HTTP 405 error.

In the log file of IIS, I can see that this is refused because POST verb is not allowed.

问题:如何为这些请求允许POST动词?
我是否必须添加WSDL文件的映射?如果我这样做,我该如何配置此映射?我检查过,在现有的映射中,我没有WSDL扩展.

是否可能在IIS上设置另一个允许这些请求的东西?

Web服务是使用WCF构建的.

c# iis wcf http-post

10
推荐指数
2
解决办法
3万
查看次数

解析XML HttpResponse

我正在尝试将我从HttpPost获取的XML HttpResponse解析为服务器(last.fm),用于last.fm android应用程序.如果我简单地将其解析为字符串,我可以看到它是一个普通的xml字符串,包含所有需要的信息.但我只是无法解析单个NameValuePairs.这是我的HttpResponse对象:

HttpResponse response = client.execute(post);
HttpEntity r_entity = response.getEntity();
Run Code Online (Sandbox Code Playgroud)

我尝试了两种不同的东西,而不是它们都有效.首先,我试图检索NameValuePairs:

List<NameValuePair> answer = URLEncodedUtils.parse(r_entity);
String name = "empty";
String playcount = "empty";
for (int i = 0; i < answer.size(); i++){
   if (answer.get(i).getName().equals("name")){
      name = answer.get(i).getValue();
   } else if (answer.get(i).getName().equals("playcount")){
      playcount = answer.get(i).getValue();
   }
}
Run Code Online (Sandbox Code Playgroud)

在此代码之后,name和playcount保持"空".所以我尝试使用XML Parser:

DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document answer = db.parse(new DataInputStream(r_entity.getContent()));
NodeList nl = answer.getElementsByTagName("playcount");
String playcount = "empty";
for (int i = 0; i < nl.getLength(); i++) {
   Node n = nl.item(i); …
Run Code Online (Sandbox Code Playgroud)

xml parsing android httpresponse http-post

10
推荐指数
1
解决办法
2万
查看次数

urllib2 POST进度监控

我正在通过POST将带有urllib2的相当大的文件上传到服务器端脚本.我想显示一个显示当前上传进度的进度指示器.是否有urllib2提供的钩子或回调,允许我监控上传进度?我知道您可以通过连续调用连接的read()方法进行下载,但是我没有看到write()方法,只是向请求添加数据.

python http urllib2 http-post

10
推荐指数
1
解决办法
4603
查看次数

如何使用gziped内容发送HTTP POST请求?

我正在开发iPhone应用程序并手动构建POST请求.目前,需要在发送之前压缩JSON数据,以便了解如何告知服务器内容是否已压缩.将内容类型标头设置为gzip可能是不可接受的,因为服务器需要JSON数据.我正在寻找透明的解决方案,就像添加一些标题,告诉JSON数据压缩成gzip.

我知道,标准的方法是告诉服务器客户端接受编码,但是你需要首先使用accept编码头发出GET请求.就我而言,我想发布已编码的数据.

iphone gzip http objective-c http-post

10
推荐指数
2
解决办法
7678
查看次数

在HttpResponse execute for android中,主机名可能不为null

我收到错误"目标主机不能为空,或在参数中设置".

  • I DO具有Internet权限在我的清单文件
  • 我把"http://"放在我的网址之前
  • 我会对 URL进行编码

这是我的代码:

   String url = "http://maps.google.com/maps/api/directions/json?origin=1600 Pennsylvania Avenue NW, Washington, DC 20500&destination=1029 Vermont Ave NW, Washington, DC 20005&sensor=false";
   HttpClient httpclient = new DefaultHttpClient();
   String goodURL = convertURL(url);//change weird characters for %etc
   HttpPost httppost = new HttpPost(goodURL);
   HttpResponse response = httpclient.execute(httppost);
Run Code Online (Sandbox Code Playgroud)

在第5行(上面的最后一行),我的程序抛出异常.这是确切的错误:

java.lang.IllegalArgumentException: Host name may not be null
Run Code Online (Sandbox Code Playgroud)

我在方法convertURL中编码我的字符串...

goodURL = http://maps.google.com/maps/api/directions/json?origin=3%20Cedar%20Ave%2c%20Highland%20Park%2c%20NJ%2008904&destination=604%20Bartholomew%20Road%2c%20Piscataway%2c%20New%20Jersey%2008854&sensor=false

有什么建议?谢谢!

android httpresponse http-post illegalargumentexception

10
推荐指数
1
解决办法
3万
查看次数

为POST Web API使用可选的复杂类型操作参数

我正在尝试使用以下原型编写API:

[HttpPost]
public ApplicationStatus appLogIn(string id, UserCredentials userCredentials = null)
Run Code Online (Sandbox Code Playgroud)

但是当我向这个API提出请求时,无论有没有userCredentials,我都会得到以下错误,响应代码为500

{
  "Message": "An error has occurred.",
  "ExceptionMessage": "Optional parameter 'userCredentials' is not supported by 'FormatterParameterBinding'.",
  "ExceptionType": "System.InvalidOperationException",
  "StackTrace": null
}
Run Code Online (Sandbox Code Playgroud)

如果我不将userCredentials作为可选项,一切正常.userCredential定义如下:

public class UserCredentials
{
    public string password { get; set; }
    public string username { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

asp.net http-post restful-architecture asp.net-web-api

10
推荐指数
1
解决办法
3441
查看次数

System.Web.Mvc.HttpPostAttribute vs System.Web.Http.HttpPostAttribute?

在我的基于ASP.NET MVC的Web API项目中,我想使用该HttpPost属性.当我将其添加到动作中时,IntelliSense会向我推荐这两个命名空间:

  • System.Web.Mvc.HttpPostAttribute
  • System.Web.Http.HttpPostAttribute

应该使用哪一个?为什么?

c# asp.net-mvc http-post asp.net-web-api

10
推荐指数
1
解决办法
3378
查看次数

如何告诉Django不要缓冲HTTP POST数据?

客户端将mjpeg流发布为HTTP POST:

POST /feed/testfeed HTTP/1.0
Content-type: multipart/x-mixed-replace; boundary=--myboundary

--myboundary
Content-length: 14179
Content-type: image/jpeg

....JFIF....
....
Run Code Online (Sandbox Code Playgroud)

我看不到Django中的传入数据.request.read(6)返回空字符串.我添加了假的"content-Length"标题:

POST /feed/testfeed HTTP/1.0
Content-Length: -1
Content-type: multipart/x-mixed-replace; boundary=--myboundary

...
Run Code Online (Sandbox Code Playgroud)

现在它以最大速度读取整个数据.request.read(6)仅在我中断连接后才返回(包含整个数据,而不仅仅是预期的6个字节).

当我使用"PUT"请求而不是"POST"请求时,行为相同.

如何关闭POST请求的缓冲?

python django http-post buffering

9
推荐指数
1
解决办法
895
查看次数

发布字符串数组

我该如何处理输入数组

例如我在我看来:

<input type="text" name="listStrings[0]"  /><br />
<input type="text" name="listStrings[1]"  /><br />
<input type="text" name="listStrings[2]" /><br />
Run Code Online (Sandbox Code Playgroud)

在我的控制中,我试着获得如下值:

[HttpPost]
public ActionResult testMultiple(string[] listStrings)
{
    viewModel.listStrings = listStrings;
    return View(viewModel);
}
Run Code Online (Sandbox Code Playgroud)

在调试,我可以看到listStrings的null每一次.

为什么它为null,如何获取输入数组的值

arrays asp.net-mvc http-post asp.net-mvc-5

9
推荐指数
1
解决办法
6255
查看次数

在Google App Engine日志中查看POST请求的参数

我有一台运行在Google App Engine上的服务器。

我正在通过控制台查看服务器的请求日志。

它们位于下Google Cloud Platform --> Stackdriver Logging --> Logs。

我想查看POST请求的参数。


使用GET-Request很容易,因为它们在条目标题中可见。

在条目的下面,它们也可行protoPayload --> resource。

但是,使用POST请求时,找不到它们。

这是我的选择:

  • metadata
  • protoPayload
  • insertId
  • log
  • httpRequest
  • operation

这些选项似乎都不包含请求的参数。

从这个答案中,我知道它们应该在请求体内。

如何在GAE日志中找到它们?

post google-app-engine http http-post httprequest

9
推荐指数
1
解决办法
2425
查看次数