Sorry, the code I wrote in my previous post is just an example I edit.

Here is the real code:

public class Main {

        String host = "192.168.0.52";
        
        String scheme = "https";
        
        int port = 443;
        
        String fileSendUrl = "/order/test";
        
        File[] files = {
                new File("F:\\materials\\sessionid\\order.xml"),
        };
        
        public void run() {
                
                long startTime = System.currentTimeMillis();
                try {
                        System.out.println("URL: " + sendFile());
                } catch (IOException e) {
                        e.printStackTrace();
                }
                long finishTime = System.currentTimeMillis();
                System.out.println("Time: " + (double)((finishTime - startTime) / 
1000.0) + " (sec)");
                
        }
        
        public String sendFile() throws IOException {
                HttpClient httpClient = new HttpClient();
                HostConfiguration hostConfig = httpClient.getHostConfiguration();
                hostConfig.setHost(host, port, scheme);
                
                MultipartPostMethod multipartPostMethod = new MultipartPostMethod();
                multipartPostMethod.setPath(fileSendUrl);
                
                multipartPostMethod.addParameter("phase", "send");
                
                try {
                        FilePart filePart = new FilePart(files[0].getName(), 
files[0].getName(), files[0]);
                        multipartPostMethod.addPart(filePart);
                } catch (FileNotFoundException e) {
                        e.printStackTrace();
                }
                
                int statusCode = -1;
                String str = null;
                try {
                        statusCode = httpClient.executeMethod(multipartPostMethod);
                        str = multipartPostMethod.getResponseBodyAsString();

                } catch (HttpException e) {
                        e.printStackTrace();
                } finally {
                        multipartPostMethod.releaseConnection();
                }
                
                return str;
        }
        
        public static void main(String[] args) {
                System.setProperty("org.apache.commons.logging.Log", 
"org.apache.commons.logging.impl.SimpleLog");
                
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
                
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire ", 
"debug");
                
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
 "trace");
                
                Main main = new Main();
                main.run();
        }

}



Result:

2003/03/07 11:52:31:692 JST [TRACE] MultipartPostMethod - -enter addParameter(String 
parameterName, String parameterValue)
2003/03/07 11:52:31:712 JST [TRACE] StringPart - -enter StringPart(String, String, 
String)
2003/03/07 11:52:31:712 JST [TRACE] FilePart - -enter FilePart(String, PartSource, 
String, String)
2003/03/07 11:52:31:722 JST [TRACE] MultipartPostMethod - -enter addPart(Part part)
2003/03/07 11:52:31:722 JST [TRACE] HttpClient - -enter 
HttpClient.executeMethod(HttpMethod)
2003/03/07 11:52:31:722 JST [TRACE] HttpClient - -enter 
HttpClient.executeMethod(HostConfiguration,HttpMethod)
2003/03/07 11:52:31:742 JST [DEBUG] HttpConnection - 
-HttpConnectionManager.getConnection:  creating  connection for 192.168.0.52:443 via 
null:-1 using protocol: https:443
2003/03/07 11:52:31:742 JST [DEBUG] HttpConnection - -HttpConnection.setSoTimeout(0)
2003/03/07 11:52:31:742 JST [TRACE] HttpConnection - -enter HttpConnection.open()
2003/03/07 11:52:36:909 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.execute(HttpState, HttpConnection)
2003/03/07 11:52:36:919 JST [TRACE] Authenticator - -enter 
Authenticator.authenticate(HttpMethod, HttpState)
2003/03/07 11:52:36:919 JST [TRACE] Authenticator - -enter 
Authenticator.authenticate(HttpMethod, HttpState, Header, String)
2003/03/07 11:52:36:919 JST [DEBUG] HttpMethod - -Execute loop try 1
2003/03/07 11:52:36:919 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.processRequest(HttpState, HttpConnection)
2003/03/07 11:52:36:929 JST [TRACE] HttpMethod - -Attempt number 1 to write request
2003/03/07 11:52:36:929 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.writeRequest(HttpState, HttpConnection)
2003/03/07 11:52:36:929 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.writeRequestLine(HttpState, HttpConnection)
2003/03/07 11:52:36:929 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.generateRequestLine(HttpConnection, String, String, String, String)
2003/03/07 11:52:36:959 JST [TRACE] HttpConnection - -enter 
HttpConnection.print(String)
2003/03/07 11:52:36:959 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[])
2003/03/07 11:52:36:959 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[], int, int)
2003/03/07 11:52:37:270 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.writeRequestHeaders(HttpState,HttpConnection)
2003/03/07 11:52:37:270 JST [TRACE] MultipartPostMethod - -enter 
MultipartPostMethod.addRequestHeaders(HttpState state, HttpConnection conn)
2003/03/07 11:52:37:270 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.addRequestHeaders(HttpState, HttpConnection)
2003/03/07 11:52:37:270 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.addUserAgentRequestHeaders(HttpState, HttpConnection)
2003/03/07 11:52:37:270 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.addHostRequestHeader(HttpState, HttpConnection)
2003/03/07 11:52:37:270 JST [DEBUG] HttpMethod - -Adding Host request header
2003/03/07 11:52:37:270 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.addCookieRequestHeader(HttpState, HttpConnection)
2003/03/07 11:52:37:290 JST [TRACE] HttpState - -enter HttpState.getCookies()
2003/03/07 11:52:37:300 JST [TRACE] CookieSpec - -enter CookieSpecBase.match(String, 
int, String, boolean, Cookie[])
2003/03/07 11:52:37:300 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.addAuthorizationRequestHeader(HttpState, HttpConnection)
2003/03/07 11:52:37:300 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.addProxyAuthorizationRequestHeader(HttpState, HttpConnection)
2003/03/07 11:52:37:300 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.addContentLengthRequestHeader(HttpState, HttpConnection)
2003/03/07 11:52:37:300 JST [TRACE] MultipartPostMethod - -enter 
MultipartPostMethod.getRequestContentLength()
2003/03/07 11:52:37:300 JST [TRACE] Part - -getLengthOfParts(Parts[])
2003/03/07 11:52:37:300 JST [TRACE] Part - -enter length()
2003/03/07 11:52:37:300 JST [TRACE] Part - -enter sendStart(OutputStream out)
2003/03/07 11:52:37:300 JST [TRACE] Part - -enter sendDispositionHeader(OutputStream 
out)
2003/03/07 11:52:37:310 JST [TRACE] Part - -enter sendContentTypeHeader(OutputStream 
out)
2003/03/07 11:52:37:310 JST [TRACE] Part - -enter 
sendTransferEncodingHeader(OutputStream out)
2003/03/07 11:52:37:310 JST [TRACE] Part - -enter sendEndOfHeader(OutputStream out)
2003/03/07 11:52:37:310 JST [TRACE] Part - -enter sendEnd(OutputStream out)
2003/03/07 11:52:37:310 JST [TRACE] StringPart - -enter lengthOfData()
2003/03/07 11:52:37:310 JST [TRACE] Part - -enter length()
2003/03/07 11:52:37:310 JST [TRACE] Part - -enter sendStart(OutputStream out)
2003/03/07 11:52:37:310 JST [TRACE] FilePart - -enter 
sendDispositionHeader(OutputStream out)
2003/03/07 11:52:37:310 JST [TRACE] Part - -enter sendDispositionHeader(OutputStream 
out)
2003/03/07 11:52:37:320 JST [TRACE] Part - -enter sendContentTypeHeader(OutputStream 
out)
2003/03/07 11:52:37:320 JST [TRACE] Part - -enter 
sendTransferEncodingHeader(OutputStream out)
2003/03/07 11:52:37:320 JST [TRACE] Part - -enter sendEndOfHeader(OutputStream out)
2003/03/07 11:52:37:320 JST [TRACE] Part - -enter sendEnd(OutputStream out)
2003/03/07 11:52:37:320 JST [TRACE] FilePart - -enter lengthOfData()
2003/03/07 11:52:37:320 JST [TRACE] HttpConnection - -enter 
HttpConnection.print(String)
2003/03/07 11:52:37:320 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[])
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[], int, int)
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.print(String)
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[])
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[], int, int)
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.print(String)
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[])
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[], int, int)
2003/03/07 11:52:37:330 JST [TRACE] HttpConnection - -enter 
HttpConnection.print(String)
2003/03/07 11:52:37:340 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[])
2003/03/07 11:52:37:340 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[], int, int)
2003/03/07 11:52:37:340 JST [TRACE] HttpConnection - -enter 
HttpConnection.print(String)
2003/03/07 11:52:37:340 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[])
2003/03/07 11:52:37:340 JST [TRACE] HttpConnection - -enter 
HttpConnection.write(byte[], int, int)
2003/03/07 11:52:37:350 JST [TRACE] HttpConnection - -enter HttpConnection.writeLine()
2003/03/07 11:52:37:350 JST [TRACE] MultipartPostMethod - -enter 
MultipartPostMethod.writeRequestBody(HttpState state, HttpConnection conn)
2003/03/07 11:52:37:350 JST [DEBUG] MultipartPostMethod - -Expecting response
2003/03/07 11:52:37:350 JST [TRACE] HttpConnection - -enter 
HttpConnection.waitForResponse(int)
2003/03/07 11:52:40:354 JST [DEBUG] HttpConnection - -Waiting for response timeout
2003/03/07 11:52:40:354 JST [DEBUG] HttpMethod - -Response not available. Send the 
request body
2003/03/07 11:52:40:354 JST [TRACE] HttpMethod - -enter 
writeRemainingRequestBody(HttpState, HttpConnection)
2003/03/07 11:52:40:354 JST [TRACE] MultipartPostMethod - -enter 
MultipartPostMethod.writeRequestBody(HttpState state, HttpConnection conn)
2003/03/07 11:52:40:354 JST [TRACE] HttpConnection - -enter 
HttpConnection.getRequestOutputStream()
2003/03/07 11:52:40:354 JST [TRACE] Part - -enter sendParts(OutputStream out, Parts[])
2003/03/07 11:52:40:354 JST [TRACE] Part - -enter send(OutputStream out)
2003/03/07 11:52:40:354 JST [TRACE] Part - -enter sendStart(OutputStream out)
2003/03/07 11:52:40:354 JST [TRACE] Part - -enter sendDispositionHeader(OutputStream 
out)
2003/03/07 11:52:40:354 JST [TRACE] Part - -enter sendContentTypeHeader(OutputStream 
out)
2003/03/07 11:52:40:364 JST [TRACE] Part - -enter 
sendTransferEncodingHeader(OutputStream out)
2003/03/07 11:52:40:364 JST [TRACE] Part - -enter sendEndOfHeader(OutputStream out)
2003/03/07 11:52:40:364 JST [TRACE] StringPart - -enter sendData(OutputStream)
2003/03/07 11:52:40:364 JST [TRACE] Part - -enter sendEnd(OutputStream out)
2003/03/07 11:52:40:364 JST [TRACE] Part - -enter send(OutputStream out)
2003/03/07 11:52:40:364 JST [TRACE] Part - -enter sendStart(OutputStream out)
2003/03/07 11:52:40:374 JST [TRACE] FilePart - -enter 
sendDispositionHeader(OutputStream out)
2003/03/07 11:52:40:374 JST [TRACE] Part - -enter sendDispositionHeader(OutputStream 
out)
2003/03/07 11:52:40:374 JST [TRACE] Part - -enter sendContentTypeHeader(OutputStream 
out)
2003/03/07 11:52:40:374 JST [TRACE] Part - -enter 
sendTransferEncodingHeader(OutputStream out)
2003/03/07 11:52:40:374 JST [TRACE] Part - -enter sendEndOfHeader(OutputStream out)
2003/03/07 11:52:40:374 JST [TRACE] FilePart - -enter sendData(OutputStream out)
2003/03/07 11:52:40:374 JST [TRACE] FilePart - -enter lengthOfData()
2003/03/07 11:52:40:374 JST [TRACE] Part - -enter sendEnd(OutputStream out)
2003/03/07 11:52:40:384 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.readResponse(HttpState, HttpConnection)
2003/03/07 11:52:40:384 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.readStatusLine(HttpState, HttpConnection)
2003/03/07 11:52:40:384 JST [TRACE] HttpConnection - -enter HttpConnection.readLine()
2003/03/07 11:52:40:384 JST [TRACE] HttpParser - -enter HttpConnection.readLine()
2003/03/07 11:52:40:394 JST [TRACE] HttpParser - -enter HttpConnection.readRawLine()
2003/03/07 11:52:40:394 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.readResponseHeaders(HttpState,HttpConnection)
2003/03/07 11:52:40:394 JST [TRACE] HttpConnection - -enter 
HttpConnection.getResponseInputStream()
2003/03/07 11:52:40:394 JST [TRACE] HttpParser - -enter 
HeaderParser.parseHeaders(HttpConnection, HeaderGroup)
2003/03/07 11:52:40:394 JST [TRACE] HttpParser - -enter HttpConnection.readLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readRawLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readRawLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readRawLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readRawLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readLine()
2003/03/07 11:52:40:404 JST [TRACE] HttpParser - -enter HttpConnection.readRawLine()
2003/03/07 11:52:40:414 JST [TRACE] HttpParser - -enter HttpConnection.readLine()
2003/03/07 11:52:40:414 JST [TRACE] HttpParser - -enter HttpConnection.readRawLine()
2003/03/07 11:52:40:414 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.processResponseHeaders(HttpState, HttpConnection)
2003/03/07 11:52:40:414 JST [TRACE] CookieSpec - -enter CookieSpecBase.parse(String, 
port, path, boolean, String)
2003/03/07 11:52:40:414 JST [TRACE] CookieSpec - -enter CookieSpecBase.parse(String, 
port, path, boolean, Header)
2003/03/07 11:52:40:424 JST [TRACE] HeaderElement - -enter HeaderElement.parse(String)
2003/03/07 11:52:40:424 JST [TRACE] HeaderElement - -enter 
HeaderElement.parsePair(char[], int, int)
2003/03/07 11:52:40:424 JST [TRACE] HeaderElement - -enter 
HeaderElement.parsePair(char[], int, int)
2003/03/07 11:52:40:424 JST [TRACE] HeaderElement - -enter 
HeaderElement.parsePair(char[], int, int)
2003/03/07 11:52:40:424 JST [TRACE] HeaderElement - -enter 
HeaderElement.parsePair(char[], int, int)
2003/03/07 11:52:40:474 JST [TRACE] Cookie - -enter Cookie(String, String, String, 
String, Date, boolean)
2003/03/07 11:52:40:474 JST [DEBUG] CookieSpec - -Unrecognized cookie attribute: 
name=Discard, value=null
2003/03/07 11:52:40:474 JST [TRACE] CookieSpec - -enter RFC2109Spec.validate(String, 
int, String, boolean, Cookie)
2003/03/07 11:52:40:484 JST [TRACE] CookieSpec - -enter 
CookieSpecBase.validate(String, port, path, boolean, Cookie)
2003/03/07 11:52:40:484 JST [TRACE] HttpState - -enter HttpState.addCookie(Cookie)
2003/03/07 11:52:40:484 JST [TRACE] CookieSpec - -enter 
RFC2109Spec.formatCookie(Cookie)
2003/03/07 11:52:40:484 JST [TRACE] CookieSpec - -enter 
RFC2109Spec.formatCookieAsVer(Cookie)
2003/03/07 11:52:40:484 JST [DEBUG] HttpMethod - -Cookie accepted: "$Version="1"; 
JSESSIONID="ncj1a1hb11"; $Path="/order""
2003/03/07 11:52:40:484 JST [TRACE] GetMethod - -enter 
GetMethod.readResponseBody(HttpState, HttpConnection)
2003/03/07 11:52:40:484 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.readResponseBody(HttpState, HttpConnection)
2003/03/07 11:52:40:484 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.readResponseBody(HttpState, HttpConnection)
2003/03/07 11:52:40:484 JST [TRACE] HttpConnection - -enter 
HttpConnection.getResponseInputStream()
2003/03/07 11:52:40:484 JST [TRACE] HttpMethod - -enter 
HttpMethodBase.canResponseHaveBody(int)
2003/03/07 11:52:40:495 JST [TRACE] GetMethod - -enter GetMethod.getResponseBody()
2003/03/07 11:52:40:495 JST [TRACE] GetMethod - -enter 
GetMethod.getResponseBodyAsStream()
java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:168)
        at com.sun.net.ssl.internal.ssl.InputRecord.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275)
        at com.sun.net.ssl.internal.ssl.AppInputStream.read(DashoA6275)
        at java.io.FilterInputStream.read(FilterInputStream.java:111)
        at 
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:142)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)
        at 
org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:161)
        at 
org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:667)
        at 
org.apache.commons.httpclient.methods.GetMethod.getResponseBody(GetMethod.java:293)
        at 
org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:717)
        at Main.sendFile(Main.java:79)
        at Main.run(Main.java:49)
        at Main.main(Main.java:97)
2003/03/07 11:52:40:495 JST [ERROR] HttpMethod - -getResponseBody failed 
<java.net.SocketException: Connection reset>
2003/03/07 11:52:40:515 JST [DEBUG] HttpMethod - -Should close connection since using 
HTTP/1.0.
2003/03/07 11:52:40:515 JST [TRACE] HttpConnection - -enter HttpConnection.close()
2003/03/07 11:52:40:515 JST [TRACE] HttpConnection - -enter 
HttpConnection.closeSockedAndStreams()
2003/03/07 11:52:40:515 JST [TRACE] HttpConnection - -enter 
HttpConnection.releaseConnection()
URL: null
Time: 9.053 (sec)




--
Marineroad Inc. / TANAKA Yuui <[EMAIL PROTECTED]>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to