1.自定义一个Student 数据类型:

package com.chnic.webservice;

import java.io.Serializable;

public class Student implements Serializable {

private String id;
 private String name;

public Student() {}

public Student(String id, String name) {
  super();
  this.id = id;
  this.name = name;
 }

public String getId() {
  return id;
 }

public void setId(String id) {
  this.id = id;
 }

public String getName() {
  return name;
 }

public void setName(String name) {
  this.name = name;
 }
 
}

2.写Service程序:

package  com.chnic.webservice;   
  
public   class  HelloWorld {   
       
     public  HelloWorld(){} 
    
     public Student getStudentInfo(){
      Student a = new Student("001","noodles");
         return a;
     }
       
}

3.将上述文件部署至axis的class目录,并对server-config.wsdd文件进行相关描述:

<deployment  xmlns = "http://xml.apache.org/axis/wsdd/"  
            xmlns:java = "http://xml.apache.org/axis/wsdd/providers/java">
       
     <service   name = "HelloWorld"   provider = "java:RPC">   
     <parameter   name = "className"   value = "com.chnic.webservice.HelloWorld"/>   
     <parameter   name = "allowedMethods"   value = "*"/>   
     <beanMapping qname="myNS:Student" xmlns:myNS="urn:HelloWorld" languageSpecificType="java:com.chnic.webservice.Student"/>
    </service>   
</deployment>

4.重启tomcat,清空/tomcat/work,删除server-config.wsdd文件进行重新部署.

通过http://localhost:8080/axis/servlet/AxisServlet查看所部署的服务.

5.客户端写测试:

package  com.chnic.test;   
  
import  java.net.URL;   
import  javax.xml.namespace.QName;   
import  org.apache.axis.client.Call;   
import  org.apache.axis.client.Service;   
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.BeanSerializerFactory;

import com.chnic.webservice.Student;
  
public   class  Test {    
        
 public   static   void  main(String[] args)  throws  Exception{   
      String targetEendPoint =  "http://localhost:7070/axis/services/HelloWorld" ;   
      Service service =  new  Service();   
      Call call = (Call) service.createCall(); 
     
      QName qn = new QName("urn:HelloWorld","Student");
      call.registerTypeMapping(Student.class, qn,
        new BeanSerializerFactory(Student.class,qn),
        new BeanDeserializerFactory(Student.class,qn));
     
      call.setTargetEndpointAddress( new  URL(targetEendPoint));   
      call.setOperationName( new  QName(targetEendPoint,  "getStudentInfo" ));
      call.setReturnClass(Student.class);
     
      Student s = (Student) call.invoke( new  Object[]{}); 
     
      System.out.println(s.getName()+ " ’s id is: "  + s.getId());

}
}

webService返回自定义类型的数据处理的更多相关文章

  1. MyBatis中Mapper的返回值类型

    insert.update.delete语句的返回值类型 对数据库执行修改操作时,数据库会返回受影响的行数. 在MyBatis(使用版本3.4.6,早期版本不支持)中insert.update.del ...

  2. ResultMap和ResultType在使用中的区别、MyBatis中Mapper的返回值类型

    在使用mybatis进行数据库连接操作时对于SQL语句返回结果的处理通常有两种方式,一种就是resultType另一种就是resultMap,下面说下我对这两者的认识和理解 resultType:当使 ...

  3. webservice调用接口,接口返回数组类型

    1. 其中sendSyncMsg1接口是方法名,Vector实现了List接口,xml是sendSyncMsg1的方法形参 Service service = new Service(); Call ...

  4. WebApi 接口返回值不困惑:返回值类型详解。IHttpActionResult、void、HttpResponseMessage、自定义类型

    首先声明,我还没有这么强大的功底,只是感觉博主写的很好,就做了一个复制,请别因为这个鄙视我,博主网址:http://www.cnblogs.com/landeanfen/p/5501487.html ...

  5. CXF2.7整合spring发布webservice,返回值类型是Map和List<Map>类型

    在昨天研究了发布CXF发布webservice之后想着将以前的项目发布webservice接口,可是怎么也发布不起来,服务启动失败,原来是自己的接口有返回值类型是Map. 研究了一番之后,发现: we ...

  6. 【Spring】利用spring的JdbcTemplate查询返回结果映射到自定义类型

    // org.springframework.jdbc.core.JdbcTemplate 中的查询方法基本都有支持参数RowMapper<T> rowMapper的重载方法.下面只是随便 ...

  7. 05 SpringMVC:02.参数绑定及自定义类型转换&&04.SpringMVC返回值类型及响应数据类型&&05.文件上传&&06.异常处理及拦截器

    springMVC共三天 第一天: 01.SpringMVC概述及入门案例 02.参数绑定及自定义类型转换 03.SpringMVC常用注解 第二天: 04.SpringMVC返回值类型及响应数据类型 ...

  8. 【转】java 访问.net webservice返回的数据集

    转自[转的也是转的][http://blog.csdn.net/fox123871/article/details/8637839] 1. 概述 很多正在开发或者打算开发XML Web Service ...

  9. java通过poi读取excel中的日期类型数据或自定义类型日期

    Java 读取Excel表格日期类型数据的时候,读出来的是这样的  12-十月-2019,而Excel中输入的是 2019/10/12 或 2019-10-12 poi处理excel时,当excel没 ...

随机推荐

  1. 详解C++ friend关键字

    1. 为什么要使用友元? 通常对于普通函数来说,要访问类的保护成员是不可能的,如果想这么做那么必须把类的成员都生命成为 public( 共用的) ,然而这做带来的问题遍是任何外部函数都可以毫无约束的访 ...

  2. USB HID Report Descriptor 报告描述符详解

    Report descriptors are composed of pieces of information. Each piece of information is called an Ite ...

  3. hibernate连接数据库,进行操作的步骤

    //初始化 Configuration conf=null; SessionFactory sf=null; Session session=null; Transaction tx=null; tr ...

  4. scala学习笔记-集合

    变长数组:数组缓冲 Scala中对于那种长度会变的数组的数据结构为ArrayBuffer. import scala.collection.mutable.ArrayBuffer; // 一个空的数组 ...

  5. apt-get install jdk

    怕忘记,记录下: sudo apt-get install python-software-properties sudo add-apt-repository ppa:webupd8team/jav ...

  6. poj1611 简单并查集

    The Suspects Time Limit: 1000MS   Memory Limit: 20000K Total Submissions: 32781   Accepted: 15902 De ...

  7. Thinkphp join 连接查询

    public function test ( ) { $User = M('authlist'); $rs = $User->join('left join wifi_shop on wifi_ ...

  8. windows下配置lamp环境(3)---配置PHP5.4

    下面配置php Php文件夹里有两个php.ini-*文件,随便修改一个,去掉后缀,变成php.ini (如图) 打开php.ini ,添加php扩展目录723行左右(其实放哪都无所谓,只不过php. ...

  9. 文成小盆友python-num8 面向对象中的成员,成员修饰符,特殊成员,异常处理,设计模式之单例模式

    本节主要内容: 1.面向对象中的成员 2.成员修饰符 3.特殊成员 4.异常处理 5.设计模式之单例模式 一.面向对象中的成员(类的成员) 类的成员总共可以分为3大类,每类中有不同的分支. 1.总述, ...

  10. PHP数组相加

    + 运算符把右边的数组元素(除去键值与左边的数组元素相同的那些元素)附加到左边的数组后面,但是重复的键值不会被覆盖 ,array_merge()此时会覆盖掉前面相同键名的值 如: $a=array(' ...