有这样的一个java类 实际上还有个 加密的类 我已经改成 c#的了  这个类也改了很多了  现在已经把要发送的byte流准备好了 想使用  c# 实现 下面java中发送和接收这个过程  谁能帮帮看看  不用整个程序都帮我弄 就是给我指点下  提交和接收 用c#是怎么实现的   多谢  如果有代码 就更好了          //这个URL是对外开放的,用于合作伙伴连接请求.
            URL url = new URL("http://e.picclife.com:7002/picc/Policy/ProcessPartnerRequest.jspx?type=tradeParter");
            
            HttpURLConnection g_URLConnection = (HttpURLConnection) url.openConnection();
            g_URLConnection.setRequestProperty("content-type", "text/html;charset=utf-8");  
            g_URLConnection.setDoOutput(true);
            g_URLConnection.setDoInput(true);
            
            //打开文件,该文件是请求报文.
            FileInputStream fis = new FileInputStream("D:/请求报文.xml");
            String byteTemp = fis.toString();
            
            //生成输出流对象
            OutputStream v_OutputStream = g_URLConnection.getOutputStream();
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            
            //写入文件内容
            int x = 0;
            while((x = fis.read()) != -1){
              bos.write(x);
            }
            fis.close();            System.out.println("加密前发送报文 :");
            System.out.println(new String(bos.toByteArray()));
            
            // DESPlus是加密解密类
            DESPlus desPlus = new DESPlus();
            String s = new String(bos.toByteArray());
            s = desPlus.encrypt(s);
            byte[] bytes = s.getBytes();
            System.out.println("加密后发送报文 :");
            System.out.println(s);
            
            v_OutputStream.write(bytes);
            //刷新输出流
            v_OutputStream.flush();
            int code = g_URLConnection.getResponseCode();
             System.out.println("code   " + code);        
            //获得服务器相应的输入流
            InputStream g_return = g_URLConnection.getInputStream();
            ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
            while ((x = g_return.read()) != -1) {
                bos2.write(x);
            }
            bos2.flush();            //关闭URL
            v_OutputStream.close();
            g_return.close();
            System.out.println("解密前返回报文:");
            String str = new String(bos2.toByteArray());
            System.out.println(str);
            str = desPlus.decrypt(str);
            System.out.println("解密后返回报文:");
            
            System.out.println(AbstractMarshaller.formatXML(str));

解决方案 »

  1.   

    http://msdn.microsoft.com/zh-cn/library/system.net.httpwebrequest%28v=VS.80%29.aspx
      

  2.   

    我这么写的 接收的时候异常  提示 500错误
      byte[] data = System.Text.Encoding.ASCII.GetBytes(s);            HttpWebRequest myRequest =           (HttpWebRequest)WebRequest.Create(url);
                myRequest.Method = "POST";
                myRequest.ContentType = "application/x-www-form-urlencoded";            myRequest.ContentLength = data.Length;            Stream newStream = myRequest.GetRequestStream();
                // Send the data.
                newStream.Write(data, 0, data.Length);            newStream.Close();
                // Get response
                HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();            StreamReader reader =  new StreamReader(myResponse.GetResponseStream(), Encoding.Default);           // string content1 = reader.ReadToEnd();            string t = reader.ReadToEnd();
    能帮我看下 有什么问题吗