有这样的一个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));
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));
解决方案 »
- |ZYCWPF| 一个Linq.Expressions的扩展方法在4.0是可以通过的,但如何把他转为3.5的 谢谢
- 返回一个属性,怎么有问题?我刚学不久
- 关于MSCHART的问题
- WebBrowser控件怎么能获得alert('')里的信息
- 在Winform中,我使用一个事件把图片写到Sqlserver数据库里..遇到异常
- webservices中用户认证怎么做了,c#,谢谢了
- 完不成任务 混不下去了 送所有分
- 三层结构客户端与中间层是如何通讯的?
- 应用程序中字段与数据库中不匹配
- c#InterNet选项
- 下载等!!!没见过这个是什么!!!!求帮忙
- 准备为一个朋友写个C#小应用,希望大牛们给点建议。
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();
能帮我看下 有什么问题吗