Axis调用.NET中的Web Service
来源:互联网 发布:一页知秋 百川鱼海 编辑:程序博客网 时间:2024/04/23 14:48
工程实践的子系统涉及到了点Axis调用ASP.NET开发的Web Service的方法,小结一下。
1- 使用.NET开发一个Web Service,并将接口写为如下方式:
[SoapRpcMethod(Action = "http://www.wsscore.com/isStudentLoginSuccessful/Rpc", RequestNamespace = "http://www.wsscore.com/isStudentLoginSuccessful/SU", ResponseNamespace = "http://www.my.com/isStudentLoginSuccessful/SU")]
[WebMethod]
public int isStudentLoginSuccessful(string studentID, string password)
...{
BasicStudentInfo bs = new BasicStudentInfo();
// 1:successful 0:wrong password -1:no such studentID
return bs.isLoginSuccessful(studentID,password);
}
[WebMethod]
public int isStudentLoginSuccessful(string studentID, string password)
...{
BasicStudentInfo bs = new BasicStudentInfo();
// 1:successful 0:wrong password -1:no such studentID
return bs.isLoginSuccessful(studentID,password);
}
注意[SoapRpcMethod]属性是比较重要的,涉及到RPC方式调用的Action和名字空间。
2- 使用Axis调用这个Web服务的接口:
public class DotNetWSScore ...{
public DotNetWSScore()...{}
public int isLoginSuccessful(String studentID, String password)...{
try ...{
ResourceBundle rb=ResourceBundle.getBundle("com.wsscore4student.business.service-config");
String endpoint= rb.getString("url");
System.out.println( "url is " + endpoint);
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://www.wsscore.com/isStudentLoginSuccessful/SU","isStudentLoginSuccessful"));
call.addParameter("studentID",org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN);
call.addParameter("password",org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_INT);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://www.wsscore.com/isStudentLoginSuccessful/Rpc");
int k = (Integer)call.invoke(new Object[]...{studentID,password});
System.out.println( "result is " + k + ".");
return k;
}
catch (Exception e) ...{System.err.println(e.toString());}
return -1;
}
}
这里我把发布.NET Web服务的url放在了com.wsscore4student.business.service-config.properties里面,本地包里的一个属性文件而已~ 动态读取,方便配置~
现在就可以实现Axis对.NET Web Service的调用了。
希望对大家有些用。
- Axis调用.NET中的Web Service
- .NET调用Apache Axis实现的Web Service
- 直接AXIS调用远程的web service
- java Web Service Axis调用参数问题
- VB.NET客户端调用Axis的Java Web Service实现文件上传
- JAVA+AXIS客户端调用Asp.net Web Service过程中遇到的问题及解决方法
- Axis 开发web service
- axis 创建web service
- AXIS的Web Service
- 使用Axis开发Web Service应用及调用
- [Java] 利用Axis库调用C#的Web Service
- [Java] 利用Axis库调用C#的Web Service
- [Java] 利用Axis库调用C#的Web Service
- 一个使用AXIS发布并调用Web Service的例子
- 一个简单的AXIS远程调用Web Service示例
- android通过ksoap2和axis调用web service
- java 调用.net web service
- java 调用.net Web Service
- 在Java中正确解码用Javascript:escape()编码的中文字符
- .NET中加密与解密QueryString的方法
- 统计数据后生成报表(急!!!在线等)
- 组策略提示"管理单元初始化失败"解决方法
- aix上的ora-04030错误
- Axis调用.NET中的Web Service
- 部分未公开的Windows 2000核心功能调用
- Win32汇编让你的VB也支持滚轮
- 驱动安装函数祥解
- 用户层下拦截系统api的原理与实现
- GridView 72般绝技
- 可重入性
- 正则表达式30分钟入门教程(第二版)
- Maintaining treeview state across your site in a master page, and no expandcollapse icons.