- 浏览: 897338 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (498)
- J2EE (52)
- 数据库 (17)
- java基础 (43)
- web技术 (19)
- 程序设计 (6)
- 操作系统 (18)
- IT资讯 (7)
- 我的IT生活 (12)
- 学习笔记 (9)
- Jquery (25)
- JavaScript (18)
- spring (40)
- Hibernate (12)
- Struts (10)
- YUI (2)
- Extjs (22)
- .net (0)
- Eclipse (10)
- 社会主义 (2)
- 服务器 (9)
- CSS (8)
- 网络安全 (16)
- 版本控制 (9)
- PHP (2)
- Oracle (42)
- SQL server (1)
- Mysql (11)
- 项目管理 (3)
- 开发工具使用 (10)
- SQL语句 (7)
- Perl (0)
- Shell (6)
- 漏洞 (4)
- ibatis (5)
- hacker (2)
- SQL注入 (6)
- Hacker工具 (2)
- 入侵和渗透 (7)
- 插件/组件 (2)
- 最爱开源 (5)
- 常用软件 (2)
- DOS (1)
- HTML (2)
- Android (9)
- CMS (1)
- portal (8)
- Linux (7)
- OSGI (1)
- Mina (5)
- maven (2)
- hadoop (7)
- twitter storm (2)
- sap hana (0)
- OAuth (0)
- RESTful (1)
- Nginx (4)
- flex (1)
- Dubbo (1)
- redis (1)
- springMVC (1)
- node.js (1)
- solr (2)
- Flume (1)
- MongoDB (2)
- ElasticSearch (1)
最新评论
-
M_drm:
请问要怎么设置浏览器才不报没权限呢?
用JS在页面调用本地可执行文件的方法(ACTIVEX) -
Alexniver:
官方文档。When importing data into I ...
mysql导入数据过慢 解决方法 -
camelwoo:
我记得 Criteria 可以做连接查询与子查询,也可以做分页 ...
Hibernate总结篇二 -
zhenglongfei:
楼主如果SubKeyName 这个节点不存在,怎么办??怎么用 ...
Java操作注册表 -
yxx676229549:
用log4j 2 了
logback
转自:[url] http://blog.csdn.net/baiboy4493/archive/2009/03/13/3987526.aspx [/url]
调用webservice,可以首先根据wsdl文件生成客户端,或者直接根据地址调用,下面讨论直接调用地址的两种不同方式:axis和Soap,soap方式主要是用在websphere下
axis方式调用:
soap方式调用
调用java生成的webservice
返回一维数组时
调用ASP.Net生成的webservice
调用webservice,可以首先根据wsdl文件生成客户端,或者直接根据地址调用,下面讨论直接调用地址的两种不同方式:axis和Soap,soap方式主要是用在websphere下
axis方式调用:
import java.util.Date; import java.text.DateFormat; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.namespace.QName; import java.lang.Integer; import javax.xml.rpc.ParameterMode; public class caClient { public static void main(String[] args) { try { String endpoint = "http://localhost:8080/ca3/services/caSynrochnized?wsdl"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(endpoint); call.setOperationName("addUser"); call.addParameter("userName", org.apache.axis.encoding.XMLType.XSD_DATE, javax.xml.rpc.ParameterMode.IN); call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING); call.setUseSOAPAction(true); call.setSOAPActionURI("http://www.my.com/Rpc"); //Integer k = (Integer) call.invoke(new Object[] { i, j }); //System.out.println("result is " + k.toString() + "."); String temp = "测试人员"; String result = (String)call.invoke(new Object[]{temp}); System.out.println("result is "+result); } catch (Exception e) { System.err.println(e.toString()); } } }
soap方式调用
调用java生成的webservice
import org.apache.soap.util.xml.*; import org.apache.soap.*; import org.apache.soap.rpc.*; import java.io.*; import java.net.*; import java.util.Vector; public class caService{ public static String getService(String user) { URL url = null; try { url=new URL("http://192.168.0.100:8080/ca3/services/caSynrochnized"); } catch (MalformedURLException mue) { return mue.getMessage(); } // This is the main SOAP object Call soapCall = new Call(); // Use SOAP encoding soapCall.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); // This is the remote object we're asking for the price soapCall.setTargetObjectURI("urn:xmethods-caSynrochnized"); // This is the name of the method on the above object soapCall.setMethodName("getUser"); // We need to send the ISBN number as an input parameter to the method Vector soapParams = new Vector(); // name, type, value, encoding style Parameter isbnParam = new Parameter("userName", String.class, user, null); soapParams.addElement(isbnParam); soapCall.setParams(soapParams); try { // Invoke the remote method on the object Response soapResponse = soapCall.invoke(url,""); // Check to see if there is an error, return "N/A" if (soapResponse.generatedFault()) { Fault fault = soapResponse.getFault(); String f = fault.getFaultString(); return f; } else { // read result Parameter soapResult = soapResponse.getReturnValue (); // get a string from the result return soapResult.getValue().toString(); } } catch (SOAPException se) { return se.getMessage(); } } }
返回一维数组时
Parameter soapResult = soapResponse.getReturnValue(); String[] temp = (String[])soapResult.getValue();
调用ASP.Net生成的webservice
private String HelloWorld(String uri, String u) { try { SOAPMappingRegistry smr = new SOAPMappingRegistry(); StringDeserializer sd = new StringDeserializer(); ArraySerializer arraySer = new ArraySerializer(); BeanSerializer beanSer = new BeanSerializer(); smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName( "http://tempuri.org/", "HelloWorldResult"), String.class, null, sd); smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName( "http://tempuri.org/", "temp"), String.class, beanSer, beanSer); URL url = new URL(uri); Call call = new Call(); call.setSOAPMappingRegistry(smr); call.setTargetObjectURI("urn:xmethods-Service1"); call.setMethodName("HelloWorld"); call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); Vector soapParams = new Vector(); soapParams.addElement(new Parameter("temp", String.class, u, null)); call.setParams(soapParams); Response soapResponse = call.invoke(url,"http://tempuri.org/HelloWorld"); if (soapResponse.generatedFault()) { Fault fault = soapResponse.getFault(); System.out.println(fault); } else { Parameter soapResult = soapResponse.getReturnValue(); Object obj = soapResult.getValue(); System.out.println("===" + obj); } } catch (Exception e) { e.printStackTrace(); } return null; } /** * 调用 C# 的webservice接口 * SoapRpcMethod(Action = "http://www.tangs.com/Add", * RequestNamespace = "http://www.tangs.com/T", * ResponseNamespace = "http://www.tangs.com/T", * Use = SoapBindingUse.Literal)] * * */ public static void addTest() { try { Integer i = 1; Integer j = 2; // WebService URL String service_url = "http://localhost:4079/ws/Service.asmx"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(service_url)); // 设置要调用的方法 call.setOperationName(new QName("http://www.tangs.com/T", "Add")); // 该方法需要的参数 call.addParameter("a", org.apache.axis.encoding.XMLType.XSD_INT, javax.xml.rpc.ParameterMode.IN); call.addParameter("b", org.apache.axis.encoding.XMLType.XSD_INT, javax.xml.rpc.ParameterMode.IN); // 方法的返回值类型 call.setReturnType(org.apache.axis.encoding.XMLType.XSD_INT); call.setUseSOAPAction(true); call.setSOAPActionURI("http://www.tangs.com/Add"); // 调用该方法 Integer res = (Integer) call.invoke(new Object[] { i, j }); System.out.println("Result: " + res.toString()); } catch (Exception e) { System.err.println(e); } } /** * 调用 C# 的webservice接口 * SoapRpcMethod(Action = "http://www.tangs.com/Add", * RequestNamespace = "http://www.tangs.com/T", * ResponseNamespace = "http://www.tangs.com/T", * Use = SoapBindingUse.Literal)] * * */ public static void helloTest() { try { String endpoint = "http://localhost:4079/ws/Service.asmx"; Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName("http://www.tangs.com/T", "HelloWorld")); call.setUseSOAPAction(true); call.setSOAPActionURI("http://www.tangs.com/Hello"); String res = (String) call.invoke(new Object[] { null }); System.out.println("Result: " + res); } catch (Exception e) { System.err.println(e.toString()); } }
发表评论
-
List对象排序通用方法
2014-07-29 09:21 993在数据库中查出来的列 ... -
EJBCA环境搭建
2014-04-03 17:31 1048EJBCA开发者 http://wiki.ejbca.org/ ... -
Java & Eclipse 相关内容杂记及技巧
2013-11-26 22:42 10111、Eclipse 的启动画面 A、加启动参数。如: ... -
一套貌似很牛B的Nutch相关框架视频教程
2013-10-24 09:16 1064国内首套免费的《Nutch相关框架视频教程》(1-20) ht ... -
使用Java调用百度、google搜索
2013-10-20 21:49 1398使用Java调用百度搜索 http://yangshangch ... -
HTTP文件断点上传
2013-05-14 00:10 990HTTP文件断点上传 http://www.cnblogs.c ... -
使用 Eclipse Memory Analyzer 检测内存泄漏问题
2013-05-05 19:01 820转:http://blog.csdn.net/moneyice ... -
memcached实现多个tomcat 共享一个session(转)
2013-04-23 09:49 824http://dqm926.iteye.com/blog/18 ... -
Java字符编码根本原理
2013-04-03 16:33 828Java开发中,常常会遇到乱码的问题,一旦遇到这种问题,常常就 ... -
PHP+JSON+瀑布流模式+三种风格+无限拖拽方式
2013-03-01 12:37 949http://guangqiang.iteye.com/blo ... -
openOffice 把word转换成html
2013-03-01 12:30 1136[url]http://jadethao.iteye.com/ ... -
StringUtils常用方法说明
2013-01-28 09:21 966http://www.iteye.com/topic/1128 ... -
logback
2013-01-23 09:40 1229http://yuri-liuyu.iteye.com/blo ... -
Web开发的第一课 - License
2013-01-20 13:13 1188http://fogtower.iteye.com/blog/ ... -
nginx负载resin,实现session共享-JVM_ROUTE
2012-12-24 09:23 1663NGINX负载配置: upstream bac ... -
中文排序要注意的问题
2012-12-08 10:10 1113遇到了中文排序问题,比如想用拼音排序, String[] ... -
位运算
2012-11-21 17:50 921程序中的所有数在计算 ... -
HashMap的2中遍历方式比较
2012-11-20 11:47 960http://smallnetvisitor.iteye.co ... -
SVN如何强制在提交时要求添加注释说明(windows平台)
2012-11-06 18:00 3587在项目库的hooks目录下,添加一个pre-commit.ba ... -
Java虚拟机读写其他进程的数据
2012-08-22 13:07 1094Java虚拟机读写其他进程的数据 http://axiang ...
相关推荐
webservice,soap调用, webservice,soap,积分接口调用,qq webservice调用
本案例实现使用Axis2生成.arr包发布WebService服务,并使用Axis2生成客户端代码方式调用WebService
java 调用https发布的webservice接口实例及axis包及详细说明
客户端调用webservice的方式其一 soap请求,此例子演示的是根据订单号获取订单的物流信息
WebService调用的几种方式,总结了Axis,Cxf,HttpClient,Myeclipse反向生成,XFire调用方式。
Java+Webservice调用方式详解Java+Webservice调用方式详解
本方法是用axis1.4技术,实现java客户端调用webservice。已经可实现过可行的,如果不行可加我QQ号302633进行详细解析。
axis和Soap方式调用Webservice服务完整代码。java的。
经典入门:Axis2创建webservice.pdf
WebService大讲堂之Axis2 WebService大讲堂之Axis2 WebService大讲堂之Axis2 WebService大讲堂之Axis2 WebService大讲堂之Axis2 WebService大讲堂之Axis2
C#开发核心代码,用拼接XML方式,调用封装了实体类的SOAP接口
java项目简单模拟soap型的webservice远程调用服务,内附使用说明文档方便学习和查阅,让你轻松学会soap-webservice的使用方法!
SOAP调用webservice例子,一个用SOAP调用webservice的例子
Java - Webservice调用方式详解
超简单的webservice调用demo,对hutool工具进行简单的封装,只需要输入webservice接口名、接口参数即可进行webservice接口调用,欢迎大家吐槽
Java WebService 简单实例 方式二(axis1直接调用方式)
NULL 博文链接:https://shenxueliang.iteye.com/blog/1734414
webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例webService—Axis实例
调用pb开发的webserver(SOAP 1.1) /* POST /webservice/n_webservice.asmx HTTP/1.1 Host: localhost Content-Type: application/soap+xml; charset=utf-8 Content-Length: length <soap12:Envelope xmlns:xsi=...