⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpleaxisworker.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            } catch (Exception e) {            }        }    }    protected void invokeMethodFromGet(String methodName, String args) throws Exception {    }    /**     * Read all mime headers, returning the value of Content-Length and     * SOAPAction.     * @param is         InputStream to read from     * @param contentType The content type.     * @param contentLocation The content location     * @param soapAction StringBuffer to return the soapAction into     * @param httpRequest StringBuffer for GET / POST     * @param cookie first cookie header (if doSessions)     * @param cookie2 second cookie header (if doSessions)     * @param headers HTTP headers to transfer to MIME headers     * @return Content-Length     */    private int parseHeaders(NonBlockingBufferedInputStream is,                             byte buf[],                             StringBuffer contentType,                             StringBuffer contentLocation,                             StringBuffer soapAction,                             StringBuffer httpRequest,                             StringBuffer fileName,                             StringBuffer cookie,                             StringBuffer cookie2,                             StringBuffer authInfo,                             MimeHeaders headers)            throws java.io.IOException {        int n;        int len = 0;        // parse first line as GET or POST        n = this.readLine(is, buf, 0, buf.length);        if (n < 0) {            // nothing!            throw new java.io.IOException(Messages.getMessage("unexpectedEOS00"));        }        // which does it begin with?        httpRequest.delete(0, httpRequest.length());        fileName.delete(0, fileName.length());        contentType.delete(0, contentType.length());        contentLocation.delete(0, contentLocation.length());        if (buf[0] == getHeader[0]) {            httpRequest.append("GET");            for (int i = 0; i < n - 5; i++) {                char c = (char) (buf[i + 5] & 0x7f);                if (c == ' ')                    break;                fileName.append(c);            }            log.debug(Messages.getMessage("filename01", "SimpleAxisServer", fileName.toString()));            return 0;        } else if (buf[0] == postHeader[0]) {            httpRequest.append("POST");            for (int i = 0; i < n - 6; i++) {                char c = (char) (buf[i + 6] & 0x7f);                if (c == ' ')                    break;                fileName.append(c);            }            log.debug(Messages.getMessage("filename01", "SimpleAxisServer", fileName.toString()));        } else {            throw new java.io.IOException(Messages.getMessage("badRequest00"));        }        while ((n = readLine(is, buf, 0, buf.length)) > 0) {            if ((n <= 2) && (buf[0] == '\n' || buf[0] == '\r') && (len > 0)) break;            // RobJ gutted the previous logic; it was too hard to extend for more headers.            // Now, all it does is search forwards for ": " in the buf,            // then do a length / byte compare.            // Hopefully this is still somewhat efficient (Sam is watching!).            // First, search forwards for ": "            int endHeaderIndex = 0;            while (endHeaderIndex < n && toLower[buf[endHeaderIndex]] != headerEnder[0]) {                endHeaderIndex++;            }            endHeaderIndex += 2;            // endHeaderIndex now points _just past_ the ": ", and is            // comparable to the various lenLen, actionLen, etc. values            // convenience; i gets pre-incremented, so initialize it to one less            int i = endHeaderIndex - 1;            // which header did we find?            if (endHeaderIndex == lenLen && matches(buf, lenHeader)) {                // parse content length                while ((++i < n) && (buf[i] >= '0') && (buf[i] <= '9')) {                    len = (len * 10) + (buf[i] - '0');                }                headers.addHeader(HTTPConstants.HEADER_CONTENT_LENGTH, String.valueOf(len));            } else if (endHeaderIndex == actionLen                    && matches(buf, actionHeader)) {                soapAction.delete(0, soapAction.length());                // skip initial '"'                i++;                while ((++i < n) && (buf[i] != '"')) {                    soapAction.append((char) (buf[i] & 0x7f));                }                headers.addHeader(HTTPConstants.HEADER_SOAP_ACTION, "\"" + soapAction.toString() + "\"");            } else if (server.isSessionUsed() && endHeaderIndex == cookieLen                    && matches(buf, cookieHeader)) {                // keep everything up to first ;                while ((++i < n) && (buf[i] != ';') && (buf[i] != '\r') && (buf[i] != '\n')) {                    cookie.append((char) (buf[i] & 0x7f));                }                headers.addHeader("Set-Cookie", cookie.toString());            } else if (server.isSessionUsed() && endHeaderIndex == cookie2Len                    && matches(buf, cookie2Header)) {                // keep everything up to first ;                while ((++i < n) && (buf[i] != ';') && (buf[i] != '\r') && (buf[i] != '\n')) {                    cookie2.append((char) (buf[i] & 0x7f));                }                headers.addHeader("Set-Cookie2", cookie.toString());            } else if (endHeaderIndex == authLen && matches(buf, authHeader)) {                if (matches(buf, endHeaderIndex, basicAuth)) {                    i += basicAuth.length;                    while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) {                        if (buf[i] == ' ') continue;                        authInfo.append((char) (buf[i] & 0x7f));                    }                    headers.addHeader(HTTPConstants.HEADER_AUTHORIZATION, new String(basicAuth) + authInfo.toString());                } else {                    throw new java.io.IOException(                            Messages.getMessage("badAuth00"));                }            } else if (endHeaderIndex == locationLen && matches(buf, locationHeader)) {                while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) {                    if (buf[i] == ' ') continue;                    contentLocation.append((char) (buf[i] & 0x7f));                }                headers.addHeader(HTTPConstants.HEADER_CONTENT_LOCATION, contentLocation.toString());            } else if (endHeaderIndex == typeLen && matches(buf, typeHeader)) {                while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) {                    if (buf[i] == ' ') continue;                    contentType.append((char) (buf[i] & 0x7f));                }                headers.addHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentLocation.toString());            } else {                String customHeaderName = new String(buf, 0, endHeaderIndex - 2);                StringBuffer customHeaderValue = new StringBuffer();                while (++i < n && (buf[i] != '\r') && (buf[i] != '\n')) {                    if (buf[i] == ' ') continue;                    customHeaderValue.append((char) (buf[i] & 0x7f));                }                headers.addHeader(customHeaderName, customHeaderValue.toString());            }        }        return len;    }    /**     * does tolower[buf] match the target byte array, up to the target's length?     */    public boolean matches(byte[] buf, byte[] target) {        for (int i = 0; i < target.length; i++) {            if (toLower[buf[i]] != target[i]) {                return false;            }        }        return true;    }    /**     * Case-insensitive match of a target byte [] to a source byte [],     * starting from a particular offset into the source.     */    public boolean matches(byte[] buf, int bufIdx, byte[] target) {        for (int i = 0; i < target.length; i++) {            if (toLower[buf[bufIdx + i]] != target[i]) {                return false;            }        }        return true;    }    /**     * output an integer into the output stream     * @param out       OutputStream to be written to     * @param value     Integer value to be written.     */    private void putInt(byte buf[], OutputStream out, int value)            throws java.io.IOException {        int len = 0;        int offset = buf.length;        // negative numbers        if (value < 0) {            buf[--offset] = (byte) '-';            value = -value;            len++;        }        // zero        if (value == 0) {            buf[--offset] = (byte) '0';            len++;        }        // positive numbers        while (value > 0) {            buf[--offset] = (byte) (value % 10 + '0');            value = value / 10;            len++;        }        // write the result        out.write(buf, offset, len);    }    /**     * Read a single line from the input stream     * @param is        inputstream to read from     * @param b         byte array to read into     * @param off       starting offset into the byte array     * @param len       maximum number of bytes to read     */    private int readLine(NonBlockingBufferedInputStream is, byte[] b, int off, int len)            throws java.io.IOException {        int count = 0, c;        while ((c = is.read()) != -1) {            if (c != '\n' && c != '\r') {                b[off++] = (byte) c;                count++;            }            if (count == len) break;            if ('\n' == c) {                int peek = is.peek(); //If the next line begins with tab or space then this is a continuation.                if (peek != ' ' && peek != '\t') break;            }        }        return count > 0 ? count : -1;    }    /**     * One method for all host name lookups.     */    public static String getLocalHost() {        return NetworkUtils.getLocalHostname();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -