怎么自行HTTP的POST包头,需要使用json

joseph_hsw 2013-12-20 02:40:43
目前的情况是直接在报头放json,但是响应有问题。
有哪位有经验的麻烦帮忙看下问题所在:
POST /nsaddpserver/api/userservice/addUser;jsessionid=E8E3246D3DA74AF81EFE654F3CDF0FC5?{"userId":"1234","username":"root","password":"root","accountName":"","chinaAccountName":"","roleId":"","roleName":"","email":"","mobilePhone":"","lastLoginTime":"","status":"","regionId":"","regionName":"","createTime":"","createUser":""} HTTP/1.1\r\n

Content-Type: application/json\r\n
...全文
283 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
afairycell 2013-12-28
  • 打赏
  • 举报
回复
你下载一个httpwatch捉包看看,必须先通过主域名获取cookie,再通过cookie连接网站,你必须留意Cookie的变化,喊你同事开个接口给你吧,通过接口把JSON的内容上传到服务器里就可以了。例如www.xxxxx.com?getjson={"xxx","xxx"}这样,按照楼上的post包头发到网址上(建议还是自己捉包看看)。httpwatch是window下的一个插件,android的包没研究过,不过和网址上差不多吧,手机经常直接开网站。
Butterbean 2013-12-28
  • 打赏
  • 举报
回复
不理解你为什么这么传 post的格式如下: POST / HTTP/1.1 Host: www.wrox.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1 Content-Type: application/x-www-form-urlencoded Content-Length: 40 Connection: Keep-Alive (----此处空一行----) name=Professional%20Ajax&publisher=Wiley 实例: POST /DEMOWebServices2.8/Service.asmx/CancelOrder HTTP/1.1 Host: api.efxnow.com Content-Type: application/x-www-form-urlencoded Content-Length: length UserID=string&PWD=string&OrderConfirmation=string post不支持太复杂的格式 可以考虑soap 示例如下: POST /DEMOWebServices2.8/Service.asmx HTTP/1.1 Host: api.efxnow.com Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <CancelOrder xmlns="https://api.efxnow.com/webservices2.3"> <UserID>string</UserID> <PWD>string</PWD> <OrderConfirmation>string</OrderConfirmation> </CancelOrder> </soap12:Body> </soap12:Envelope>
joseph_hsw 2013-12-20
  • 打赏
  • 举报
回复
我的意思是,我需要POST一个json的数据到服务器。 json的数据内容是: {"userId":"1234","username":"root","password":"root","accountName":"","chinaAccountName":"","roleId":"","roleName":"","email":"","mobilePhone":"","lastLoginTime":"","status":"","regionId":"","regionName":"","createTime":"","createUser":""} 目前是希望在把json的这个数据直接带在请求的路径这里。 也就是平常报头中的 “POST url HTTP_VERSION\r\n”中的url中。实例就是我在上面发的。 同事,在报头中也声明了“Content-Type: application/json\r\n ” 路径加“?”带的参数 但是服务器(tomcat)返回错误。是不是json不能直接放在这里。或者是写法有不对
DrSmart 2013-12-20
  • 打赏
  • 举报
回复
不知道啥问题

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧