xfire集成spring开发的一个数据库登陆验证实例,包含SSL安全机制
2. 如何在客户端调用使用了SSL的web service调用如下
String endpoint =
"";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("",
"echo"));
String ret = (String) call.invoke(new Object[] {"111"});
---------------------------------------------------------------
在代码开头加上下面2句即可
System.setProperty("javax.net.ssl.trustStore","yourKeystoreFilename");
System.setProperty("javax.net.ssl.trustStorePassword","keystorePassword");
注意你的keystore文件必须要事先导入服务端的证书
3.
.Net的客户端测试
只需要加入下面一句话即可:
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; |
using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Web.Services; using username;
public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
} protected void Button1_Click(object sender, EventArgs e) { System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; userservice.UserService us = new userservice.UserService(); if (us.login("test1","111111") == true) { TextBox1.Text = "True"; } else { TextBox1.Text = "fale"; }
} }
|
它的作用就是接受所有的证书,也就是在我们SSL中的流程中,检查证书CA是否受信这部分省略,就好比我们访问一些非受信证书的网站跳出的提示框我们点击确认一样。
|
文件: |
xfirelogin(SSL).rar |
大小: |
37KB |
下载: |
下载 | |
阅读(1224) | 评论(0) | 转发(0) |