http://jakarta.apache.org/commons/httpclient/downloads.html

解决方案 »

  1.   

    我实在调试不通了,那位帮忙调试一下!谢谢!
    =================
    import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
    import org.apache.commons.httpclient.methods.PostMethod;
    import java.io.File;
    import java.io.FileInputStream;/**
     * @author Danile
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    public class soap_test
    {
    public static void main(String[] args)
    {
    String strURL = "http://10.0.18.113:1920///cms/soap";
    String strXMLFilename="req.txt";
    File input = new File(strXMLFilename);
    PostMethod post=null;
    try
    {
    post = new PostMethod(strURL);
    post.setRequestEntity(new InputStreamRequestEntity(new FileInputStream(input), input.length())); // ISO-8859-1 is assumed
    post.setRequestHeader("Content-Type",  "text/xml");
    post.setRequestHeader("MessageType",   "Call");
    // Get HTTP client
    HttpClient httpclient = new HttpClient(); // Execute request
            
    int result = httpclient.executeMethod(post);
    // Display status code
    System.out.println("Response status code: " + result);
    // Display response
    System.out.println("Response body: ");
    System.out.println(post.getResponseBodyAsString());
    }
    catch(Throwable e)
    {
    e.printStackTrace();

    finally
    {
    // Release current connection to the connection pool once you are done
    post.releaseConnection();
    }
    }
    }