java axis 1.4访问c# webservice,并获取返回值为dataset
来源:互联网 发布:匈牙利佩奇大学 知乎 编辑:程序博客网 时间:2024/05/21 09:30
用java访问c# webservice时,和平时java访问自己不大一样。
try {// 创建一个服务(service)调用(call)org.apache.axis.client.Service service = new org.apache.axis.client.Service();Call call = (Call) service.createCall();// 通过service创建call对象// 设置service所在URLcall.setTargetEndpointAddress(new java.net.URL(endpoint));// 方法名(processService)与MyService.java方法名保持一致call.setOperationName(new QName("http://tempuri.org/", "GetWxyt"));call.setUseSOAPAction(true);call.setSOAPActionURI("http://tempuri.org/GetWxyt");call.addParameter(new QName("http://tempuri.org/", "ytTypeId"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);call.addParameter(new QName("http://tempuri.org/", "ytStartTime"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);call.addParameter(new QName("http://tempuri.org/", "ytEndTime"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);call.setReturnType(org.apache.axis.encoding.XMLType.XSD_SCHEMA);// ytTypeId ytStartTime ytEndTimeObject object = call.invoke(new Object[] { "1","2013-08-30 08:30:00", "2013-08-30 18:30:00" });System.out.println(object);//c#返回值的dataset类型,必须进行解析,下面是解析过程Schema schema = (Schema)object;//DefaultTableModel model=new DefaultTableModel(new String[]{"strFilePath","strMyImageBytes"},0); schema.get_any()[1].getChildNodes().getLength();int nLength=schema.get_any()[1].getChildNodes().item(0).getChildNodes().getLength();String strFilePath="";String strMyImageBytes="";JSONArray jsons = new JSONArray();for(int i=0;i<nLength;i++){ JSONObject jsonObject = new JSONObject(); if(schema.get_any()[1].getChildNodes().item(0).getChildNodes().item(i).getChildNodes().item(0).getNodeName().equals("strFilePath")){strFilePath=schema.get_any()[1].getChildNodes().item(0).getChildNodes(). item(i).getChildNodes().item(0).getFirstChild().getNodeValue();jsonObject.put("strFilePath", strFilePath);}if(schema.get_any()[1].getChildNodes().item(0).getChildNodes().item(i).getChildNodes().item(1).getNodeName().equals("strMyImageBytes")){strMyImageBytes=schema.get_any()[1].getChildNodes().item(0).getChildNodes().item(i).getChildNodes().item(1).getFirstChild().getNodeValue();jsonObject.put("strMyImageBytes", strMyImageBytes);}//model.addRow(new String[]{strFilePath,strMyImageBytes}); jsons.add(jsonObject);}System.out.println(jsons.toString());} catch (MalformedURLException e) {e.printStackTrace();} catch (RemoteException e) {e.printStackTrace();} catch (ServiceException e) {e.printStackTrace();}
其中有几个设置是不可缺少的
call.setOperationName(new QName("http://tempuri.org/", "GetWxyt"));
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://tempuri.org/GetWxyt");
http://tempuri.org/是wsdl:definitions结点下的targetNamespace结点的属性值。
call.addParameter(new QName("http://tempuri.org/", "ytTypeId"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/", "ytStartTime"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter(new QName("http://tempuri.org/", "ytEndTime"),
org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_SCHEMA);
new QName("http://tempuri.org/", "ytEndTime")这边参数也必须加上命名空间,否则会出现莫名其妙的错误。
最后面是dataset类型的返回值的获取,可以参考下。
- java axis 1.4访问c# webservice,并获取返回值为dataset
- java 中用Axis访问C#的webservice接口
- Axis Java调C# Webservice
- C# 获取xml数据,并转换为dataset
- 获取webservice 返回的 dataset 数据集 并转换成 datatable
- C#访问web,并处理返回值
- C#访问URL地址并返回值
- c# DataSet写出XML,返回为文本
- Axis接收远程调用c# webservice返回的数组
- webservice返回dataset
- C# 运行.exe 并获取返回值
- 用Jquery访问WebService并返回Json
- JAVA axis调用Asp.net发布WebService返回XmlNode数据类型
- axis实现webservice 返回对象
- java通过axis访问.net webService 简单例子
- java调用webservice axis
- Java webservice axis
- JAVA CXF、XFIRE、AXIS webservice获取客户端IP
- xdebug远程调试
- TI低功耗蓝牙(BLE)介绍
- 数据库的表复制
- ASP.NET MVC 入门11、使用AJAX
- JDBC打印执行的sql
- java axis 1.4访问c# webservice,并获取返回值为dataset
- Qt5.1 发布程序
- How to port Ubuntu 11.10 to Beagleboard 怎样移植Ubuntu 11.10 到BeagleBoard
- jndi调用时,各种应用服务器InitialContext的写法
- iOS 关于枚举的使用
- MFC 对话框半透明实现
- 使用netbeans进行PHP团队开发和基于xdebug进行多人远程调试
- 公共排序-110303/10252
- 关注的java开源项目-1