HTTP POST RETURNING BAD REQUEST错误400来自ANDROID HTTPURLConnection

时间:2015-06-29 17:38:04

标签: android wcf http post

我正在使用HTTPURLConnection类将我的Android应用程序连接到我的WCF Web服务。我正在使用Microsoft网络监视器来跟踪请求,因此它会点击我的服务器。

  • Http:Request,POST /iEService/Service.svc/register_user

命令:POST     URI:/iEService/Service.svc/register_user

Location: /iEService/Service.svc/register_user 
ProtocolVersion: HTTP/1.1
UserAgent:  Dalvik/2.1.0 (Linux; U; Android 5.0.2; A0001 Build/LRX22G)
Host:  win-server
Connection:  Keep-Alive
Accept-Encoding:  gzip
ContentType:  application/x-www-form-urlencoded
MediaType:  application/x-www-form-urlencoded
ContentLength:  183
HeaderEnd: CRLF
payload: HttpContentType =  application/x-www-form-urlencoded
 Last_Name: l_one
 Birthday: bd_one
 Email: e_one
 Username: u_one
 Business_Location: bl_one
 Security_Answer: sa_one
 Security_Question: s_one
 First_Name: f_one
 Password: p_one
 IMEI_Number: imei_one

但是,我收到错误请求错误400.我看不出请求有什么问题。可能是什么问题?

1 个答案:

答案 0 :(得分:0)

问题出在我的WCF服务方法中。我所要做的就是添加 BodyStyle:= WebMessageBodyStyle.WrappedRequest 方法标题。

它有效。

相关问题