使用WSDL2java得到客户端存根

 

存根:客户端代理(stub),用于完成底层套接字编程

骨架:服务器端代理(skeleton),也是完成底层套接字编程

 结构化方式描述

         Axis用三种方式支持WSDL

1、  url+wsdl方式获得自动生成的wsdl文档

2、  wsdl2Java工具能生成java客户端存根和服务器端骨架(常用命令-v:打印信息,-p:指定包结构 –o:输出指定的java文件到指定目录)

3、  java2WSDL工具可以通过java构建wsdl文档

 

 

Axis的Wsdl2Java可以支持生成客户端存根和骨架,下面是生成客户端存根的例子:

 

服务器端:

 

 

package cn.com.test.ce.webservice;

 

import cn.com.test.ce.pojo.Person;

 

public class Service

{

    public Person getPerson()

    {

             Person person = new Person();

                 person.setId(1);

                 person.setName("张三");

             return person;

    }

}

 

 

服务器端PoJo类:

package cn.com.test.ce.pojo;

 

public class Person {

    private Integer id;

    private String name;

    public Integer getId() {

       return id;

    }

    public void setId(Integer id) {

       this.id = id;

    }

    public String getName() {

       return name;

    }

    public void setName(String name) {

       this.name = name;

    }

   

}

 

 

客户端通过-v(打印信息) –p(指定包名) cn.com.test.webservice.service –o(指定目录名) src http://localhost:8080/MyAxisPoJoWebService/services/MyService?wsdl类似这样的命令生成客户端存根

 

 

然后客户端可以回生成以下java文件:

 

 

/**

 * MyServiceSoapBindingStub.java

 *

 * This file was auto-generated from WSDL

 * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.

 */

 

package cn.com.test.webservice.service;

 

public class MyServiceSoapBindingStub extends org.apache.axis.client.Stub implements cn.com.test.webservice.service.Service {

    private java.util.Vector cachedSerClasses = new java.util.Vector();

    private java.util.Vector cachedSerQNames = new java.util.Vector();

    private java.util.Vector cachedSerFactories = new java.util.Vector();

    private java.util.Vector cachedDeserFactories = new java.util.Vector();

 

    static org.apache.axis.description.OperationDesc [] _operations;

 

    static {

        _operations = new org.apache.axis.description.OperationDesc[1];

        _initOperationDesc1();

    }

 

    private static void _initOperationDesc1(){

        org.apache.axis.description.OperationDesc oper;

        org.apache.axis.description.ParameterDesc param;

        oper = new org.apache.axis.description.OperationDesc();

        oper.setName("getPerson");

        oper.setReturnType(new javax.xml.namespace.QName("urn:Service", "Person"));

        oper.setReturnClass(cn.com.test.webservice.service.Person.class);

        oper.setReturnQName(new javax.xml.namespace.QName("", "getPersonReturn"));

        oper.setStyle(org.apache.axis.constants.Style.RPC);

        oper.setUse(org.apache.axis.constants.Use.ENCODED);

        _operations[0] = oper;

 

    }

 

    public MyServiceSoapBindingStub() throws org.apache.axis.AxisFault {

         this(null);

    }

 

    public MyServiceSoapBindingStub(java.net.URL endpointURL, javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {

         this(service);

         super.cachedEndpoint = endpointURL;

    }

 

    public MyServiceSoapBindingStub(javax.xml.rpc.Service service) throws org.apache.axis.AxisFault {

        if (service == null) {

            super.service = new org.apache.axis.client.Service();

        } else {

            super.service = service;

        }

        ((org.apache.axis.client.Service)super.service).setTypeMappingVersion("1.2");

            java.lang.Class cls;

            javax.xml.namespace.QName qName;

            javax.xml.namespace.QName qName2;

            java.lang.Class beansf = org.apache.axis.encoding.ser.BeanSerializerFactory.class;

            java.lang.Class beandf = org.apache.axis.encoding.ser.BeanDeserializerFactory.class;

            java.lang.Class enumsf = org.apache.axis.encoding.ser.EnumSerializerFactory.class;

   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值