本帖最后由 u011339091 于 2013-12-20 14:55:05 编辑

解决方案 »

  1.   

    我的意思是,我需要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不能直接放在这里。或者是写法有不对
      

  2.   

    不理解你为什么这么传 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: lengthUserID=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>
      

  3.   

    你下载一个httpwatch捉包看看,必须先通过主域名获取cookie,再通过cookie连接网站,你必须留意Cookie的变化,喊你同事开个接口给你吧,通过接口把JSON的内容上传到服务器里就可以了。例如www.xxxxx.com?getjson={"xxx","xxx"}这样,按照楼上的post包头发到网址上(建议还是自己捉包看看)。httpwatch是window下的一个插件,android的包没研究过,不过和网址上差不多吧,手机经常直接开网站。