String cmd = "POST Http://xxx.xxx.xxx.xxx:xxxx HTTP/1.1 \r\n";
这句话改成
String cmd = "POST /Path/xxxx.html HTTP/1.1 \r\n";

解决方案 »

  1.   

    URL url = new URL(sURL);
                String host = url.getHost();
                int port = url.getPort();
                String path = url.getFile();
                if ("".equals(path)) {
                    path = "/";
                }
                Socket socket = new Socket(host, port);
                out = socket.getOutputStream();
                PrintWriter printOut = new PrintWriter(
                    new BufferedWriter(
                    new OutputStreamWriter(out, "MS932")));
                String requestLine = new StringBuffer()
                    .append("POST ")
                    .append(path)
                    .append(" HTTP/1.0")
                    .append(CR_LF)
                    .toString();
                String requestHeader = new StringBuffer()
                    .append("Host: ").append(host)
                    .append(CR_LF)
                    .append("Content-length: ").append(requestData.length())
                    .append(CR_LF)
                    .append("Content-type: ")
                    .append("application/x-www-form-urlencoded")
                    .append(CR_LF)
                    .append("Prama: ").append("no-cache")
                    .append(CR_LF)
                    .toString();
                printOut.print(requestLine);
                printOut.print(requestHeader);
                printOut.print(CR_LF); // blank
                printOut.print(requestData);
                printOut.print(CR_LF);
                printOut.flush();
      

  2.   

    返回的错误提示是这样的HTTP/1.1 405 Method Not AllowedDate: Thu, 11 Sep 2003 00:45:50 GMTServer: Apache/1.3.26 (Unix) ZXMLS G100/1.0 ZXMLS M100/1.0Vary: accept-language,accept-charsetAllow: GET, HEAD, OPTIONS, TRACEConnection: closeContent-Type: text/html; charset=iso-8859-1Expires: Thu, 11 Sep 2003 00:45:50 GMT<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><HTML><HEAD><TITLE>405 Method Not Allowed</TITLE></HEAD><BODY><H1>Method Not Allowed</H1>The requested method POST is not allowed for the URL /index.html.<P><HR><ADDRESS>Apache/1.3.26 Server at 127.0.0.1 Port 2000</ADDRESS></BODY></HTML>网关上好象不是用WEB服务器来处理的,但是数据怎么接收呢?