有一个A系统,使用WebService接口方式提供远程服务,我们现在想向这个接口发送XML文件第一种方式:
1)HTTP的POST方式向A系统发送XML文件,2)HTTPS方式向A系统发送XML文件,请问如何实现,着急,有分哦!
知道的请与我联系:
邮箱:[email protected]给个例子的代码最好,呵呵

解决方案 »

  1.   

    另外,这些方式和JAVA的socket通信有什么不同呢,呵呵,现在着急要,先提问,晚上回家我再好好百度去。多谢啊
      

  2.   

    一个建议, 你直接把 xml 文件 放到字符串中,然后把这个字符串放到一个 input 中, 直接 用 httpclient post 过去就行了
    不必要传文件
      

  3.   


    谢谢,我们是把XML进行BASE64编码,然后通过ContentType须为“application/octet-stream”,即为字节流方式传递
      

  4.   


    我通过 c# 把 要传递的内容传到服务器上的   HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(RequestAddress);
                req.Method = "POST";
                req.KeepAlive = false;
                req.ContentType = "application/x-www-form-urlencoded;charset=" + Encoding.ToString();
                req.ContentLength = postBytes.Length;你看看对你有没有用处,
    这里面少了 参数的设置
      

  5.   

    用httpClientl来通信。具体例子很多啊。baidu一下google现在不好用了。被D封了。
      

  6.   

    private static void processData() {     
      try{
     // HttpClient httpClient = new HttpClient();
       String StrSoapMsg="<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:web=\"http://WebXml.com.cn/\">"
       +"<soap:Header/>"
       +"<soap:Body>"
       +"<web:getWeatherbyCityName>"
             +"<web:theCityName>beijing</web:theCityName>"
          +"</web:getWeatherbyCityName>"
       +"</soap:Body>"
    +"</soap:Envelope>";
       String Url = strUrlService;
       URL url = new URL(Url);
       URLConnection connection = url.openConnection();   
       HttpURLConnection httpConn = (HttpURLConnection) connection;   
       httpConn.setDoOutput(true);
       httpConn.setDoInput(true);
       httpConn.setRequestMethod("POST");
       httpConn.setRequestProperty("Content-Type","application/soap+xml; charset=utf-8");//这里根据服务器情况看 一种是//application/soap+xml 还有一种是text/xml   httpConn.setRequestProperty("SOAPAction", "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
       OutputStream out = httpConn.getOutputStream();      
       Writer wout = new OutputStreamWriter(out);
       wout.write(StrSoapMsg.trim());
       wout.flush();
       wout.close();  
       
       
      /* BufferedReader rd = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
    String line = "";
    while ((line = rd.readLine()) != null) {
    System.out.print( line);  }*/
       InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
       char[] ok = new char[1024*2] ;   
       String strRead  =  "";   
       int i = 0 ;
       while (true){    
        i = i+1;
        if (i == iGetStrLong){
         break ;
        }
        if (isr.read(ok)== -1){
         strRead  = strRead + (new String(ok)).trim() ;     
         break;
        }
        else{
         strRead  = strRead + (new String(ok)).trim() ;
         ok = null;
         ok =  new  char[1024*20] ;
        }
       }
       strRead = strRead.trim();   
        
       isr.close();
       
       System.out.print(strRead.toString());
       
      } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      
      
      }
       
    }
    结贴吧  发送返回全给你写了 你只需要把发送的xml换下就行了
      

  7.   

    String Url = strUrlService; 
      URL url = new URL(Url); 
      URLConnection connection = url.openConnection();  
      HttpURLConnection httpConn = (HttpURLConnection) connection;  
      httpConn.setDoOutput(true); 
      httpConn.setDoInput(true); 
      httpConn.setRequestMethod("POST"); 
      httpConn.setRequestProperty("Content-Type","application/soap+xml; charset=utf-8");
    JDOM读取更简单些