我写了一个java调用.net web services,.net 返回的是一个xml document,我曾经采用axis来自动生成客户端的形式成功调用过,但是axis自动生成的代码可读性奇差,简直惨不忍睹。
所以我想有没有什么简化操作,自己做了点尝试,发现返回类型转换总是不成功,谁能,不胜感激!
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.w3c.dom.Document;
/**
* @author Liujj
* Date 2007-1-18 <br>
* Description: <br>
* TestUserService
*/
public class TestUserService {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
// String wsdlUrl = "http://192.168.5.149/Centralism_XH10/webservice/UserService.asmx?op=getUserInfo";
// String nameSpaceUri = "http://192.168.5.149/Centralism_XH10/webservice/UserService.asmx";
String wsdlUrl = "http://192.168.5.149/Centralism_XH10/webservice/UserService.asmx?op=getUserInfo";
String soapActionURI = "http://research.beyondbit.com/Centralism/getUserInfo";
// 创建调用对象
Service service = new Service();
Call call = (Call) service.createCall();
// 调用getUserInfo
System.out.println(">>>getUserInfo");
//xmlns
call.setOperationName(new QName("http://research.beyondbit.com/Centralism", "getUserInfo"));
call.setTargetEndpointAddress(new java.net.URL(wsdlUrl));
//parameter & return
call.addParameter("ldapStr", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter("attrNames", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_ANY);
//set soap action
call.setUseSOAPAction(true);
call.setSOAPActionURI(soapActionURI);
//call
String ret = (String) call.invoke(new Object[] { "d61b29051cd534458c0cdd16bdab77aa" , "" });
System.out.println("return value is " + ret);
} catch (Exception e) {
e.printStackTrace();
}
}
}
分享到:
- 2007-01-23 14:49
- 浏览 4993
- 评论(4)
- 论坛回复 / 浏览 (4 / 9925)
- 查看更多
相关推荐
PHP xml web services
学习programming web services with xml rpc的好资料
NET Web Services XML英文版
《2001_Programming Web Services with XML-RPC》 is about Web Services programming based on xml-rpc.
基础的Web Services(假定你没有EAI背景,最好在涉入SOA之前阅读这两本书)Enterprise Application Integration Addison-Wesley Information Technology Series) by David S. Linthicum Next Generation ...
SOAP是Web services的传输层协议,所有的SOAP消息均使用XML编码。XML engine是建立在Web service上的一种技术。在整个Web服务应用中,XML处于消息层的位置,而XML engine则针对Web服务应用中的XML进行操作,所以称做...
Web Service便是基于网络的、分布式的模块化组件,它执行特定的任务,遵守具体的技术规范,这些规范使得Web Service能与其他兼容的组件进行互操作。它可以使用标准的互联网协议,像超文本传输协议HTTP和XML,将功能...
使用Microsoft Visual C#开发XML Web Services和Server Components
Web Services 教程Web Services 教程Web Services 教程Web Services 教程
Developing .Net Web Services with XML introduces readers to the foundation for the .Net platform. The book covers the history, applications and implementation of the Extensible Markup Language within ...
It's an English version about .NET Web Services written by Damien Foggon, Daniel Maharry, Chris Ullman and Karli Watson
c# 基于反射、自定义特性、Web Services、xml序列化的应用实例 !
Programming Web Services with XML-RPC <br>Simon St. Laurent <br>Joe Johnston <br>Edd Dumbill <br>Publisher: O'Reilly <br>First Edition June 2001 ISBN: 0-596-00119-3, 230 pages
web services web services web services web services web services
在java开发services中,会用到: 1.webservices-api.jar 2.webservices-extra.jar 3.webservices-rt.jar 4.webservices-tools.jar 5.webservices-extra-api.jar 此压缩文件里就是这五个jar文件。
Web ServicesWeb ServicesWeb Services
WEB SERVICES原理与研发实践
理解WebServices xml wsdl SOAP和uddi的好东西,pdf
Exchange Web Services 2.2
J2EE Web Services: XML SOAP WSDL UDDI WS-I JAX-RPC JAXR SAAJ JAXP