Web Service之Axis实现

今天终于搞定,贴出来分享一下
1、在www.apache.org上下载Axis1.4,将解压后的Axis目录文件复制到%TOMCATHOME%\webapps目录下
2、重新启动Tomcat,访问http://localhost:8080/axis,如果能访问,表示Axis环境安装成功
3、在eclipse下建立webproject,将axis的jar包导入

写2个JavaBean,分别叫做Person.java和Book.java,代码如下

Book.java

package com.lucky.axis.service;

 

public class Book {

    private String bookname;

    private Long isbn;

    private float price;

    private Integer pages;

    public String getBookname() {

        return bookname;

    }

    public void setBookname(String bookname) {

        this.bookname = bookname;

    }

    public Long getIsbn() {

        return isbn;

    }

    public void setIsbn(Long isbn) {

        this.isbn = isbn;

    }

    public float getPrice() {

        return price;

    }

    public void setPrice(float price) {

        this.price = price;

    }

    public Integer getPages() {

        return pages;

    }

    public void setPages(Integer pages) {

        this.pages = pages;

    }

 

}

 

Person.java

package com.lucky.axis.service;

 

import java.util.Map;

 

public class Person {

    private String name;

    private int age;

    private Map skill;

    private Book mybook;

    public String getName() {

        return name;

    }

    public void setName(String name) {

        this.name = name;

    }

    public int getAge() {

        return age;

    }

    public void setAge(int age) {

        this.age = age;

    }

    public Map getSkill() {

        return skill;

    }

    public void setSkill(Map skill) {

        this.skill = skill;

    }

   public Book getMybook() {

        return mybook;

    }

    public void setMybook(Book mybook) {

        this.mybook = mybook;

    }

 

}


 


建立服务器端代码,命名为PersonInfoService.java,实现三个method,分别为public String getPersonInfo(Person person)、public Book setBookInfo(String bookname, Long isbn)、public Person getPersonInfo(),以下为全部代码:

package com.lucky.axis.service;

 

import java.util.HashMap;

import java.util.Map;

 

public class PersonInfoService {

    public PersonInfoService() {

    }

 

    public String getPersonInfo(Person person){

        String personinfo = "";

        personinfo = "Hello, " +person.getName()

                + " ! This is youinformation\r\n";

        personinfo = personinfo + "Ages:" + person.getAge() + "\r\n";

        Map skill = person.getSkill();

        String strskill = "";

        strskill = strskill +skill.get("NAME") + " : you have "

                + skill.get("YEAR") +" years experience!\r\n";

        personinfo = personinfo + strskill;

        personinfo = personinfo + "BookName : "

               +person.getMybook().getBookname() + "\r\n";

        personinfo = personinfo + "ISBN :"

                + person.getMybook().getIsbn()+ "\r\n";

        personinfo = personinfo + "You pay{1}quot;

                + person.getMybook().getPrice()+ " for this book.\r\n";

        personinfo = personinfo + "Thisbook have "

                + person.getMybook().getPages()+ " pages.\r\n";

        return personinfo;

    }

 

    public Book setBookInfo(String bookname,Long isbn) {

        Book book = new Book();

        book.setBookname(bookname);

        book.setIsbn(isbn);

        book.setPages(new Integer(265));

        book.setPrice((float) 25.65);

        return book;

    }

 

    public Person getPersonInfo() {

        Person person = new Person();

        person.setName("Aaron");

        person.setAge(26);

        Map skill = new HashMap();

        skill.put("NAME","JAVA");

        skill.put("YEAR","3");

        person.setSkill(skill);

        Book book = new Book();

        book.setBookname("<Thinking inJava>");

        book.setIsbn(new Long(456256821));

        book.setPages(new Integer(982));

        book.setPrice((float) 99.8);

        person.setMybook(book);

        return person;

    }

 

}


 



将编译好的Java类直接放在%Tomcat%\webapps\axis\WEB-INFO\classess\目录下。注意将整个包路径复制到上述目录中

在%Tomcat%\webapps\axis目录下建立 server-config.wsdd 文件,内容如下

<?xml version="1.0"encoding="UTF-8"?>

<deploymentxmlns="http://xml.apache.org/axis/wsdd/"

   xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

    <globalConfiguration>

        <parametername="sendMultiRefs" value="true" />

        <parametername="disablePrettyXML" value="true" />

        <parametername="adminPassword" value="admin" />

        <parametername="attachments.Directory"

            value="C:\Tomcat 5.0(iplanetldap)\webapps\axis\WEB-INF\attachments" />

        <parametername="axis.servicesPath" value="/mossWS/" />

        <parametername="dotNetSoapEncFix" value="true" />

        <parametername="enableNamespacePrefixOptimization"

            value="false" />

        <parametername="sendXMLDeclaration" value="true" />

        <parametername="sendXsiTypes" value="true" />

        <parametername="attachments.implementation"

           value="org.apache.axis.attachments.AttachmentsImpl" />

        <requestFlow>

            <handlertype="java:org.apache.axis.handlers.JWSHandler">

                <parametername="scope" value="session" />

            </handler>

            <handlertype="java:org.apache.axis.handlers.JWSHandler">

                <parametername="scope" value="request" />

                <parametername="extension" value=".jwr" />

            </handler>

        </requestFlow>

    </globalConfiguration>

    <handler name="Authenticate"

       type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>

    <handler name="LocalResponder"

       type="java:org.apache.axis.transport.local.LocalResponder"/>

    <handler name="URLMapper"

       type="java:org.apache.axis.handlers.http.URLMapper" />

    <handler name="soapmonitor"

       type="java:org.apache.axis.handlers.SOAPMonitorHandler">

        <parameter name="wsdlURL"

           value="/axis/SOAPMonitorService-impl.wsdl" />

        <parametername="namespace"

           value="http://tempuri.org/wsdl/2001/12/SOAPMonitorService-impl.wsdl"/>

        <parametername="serviceName" value="SOAPMonitorService" />

        <parameter name="portName"value="Demo" />

    </handler>

    <service name="AdminService"provider="java:MSG">

        <parametername="allowedMethods" value="AdminService" />

        <parametername="enableRemoteAdmin" value="false" />

        <parametername="className" value="org.apache.axis.utils.Admin" />

       <namespace>http://xml.apache.org/axis/wsdd/</namespace>

    </service>

    <servicename="SOAPMonitorService" provider="java:RPC">

        <parametername="allowedMethods" value="publishMessage" />

        <parametername="className"

           value="org.apache.axis.monitor.SOAPMonitorService" />

        <parameter name="scope"value="Application" />

    </service>

    <service name="AxisDemo"provider="java:RPC">

        <parametername="allowedMethod" value="*"></parameter>

        <parametername="className"

           value="com.lucky.axis.service.PersonInfoService">

        </parameter>

        <beanMappingqname="myNS:Person" xmlns:myNS="urn:PersonInfo"

           languageSpecificType="java:com.lucky.axis.service.Person"/>

        <beanMappingqname="myNS:Book" xmlns:myNS="urn:PersonBookInfo"

            languageSpecificType="java:com.lucky.axis.service.Book"/>

    </service>

    <transport name="http">

        <requestFlow>

            <handlertype="URLMapper" />

            <handler

               type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>

        </requestFlow>

        <parameter name="qs:list"

           value="org.apache.axis.transport.http.QSListHandler" />

        <parameter name="qs:wsdl"

           value="org.apache.axis.transport.http.QSWSDLHandler" />

        <parameter name="qs.list"

           value="org.apache.axis.transport.http.QSListHandler" />

        <parametername="qs.method"

           value="org.apache.axis.transport.http.QSMethodHandler" />

        <parametername="qs:method"

            value="org.apache.axis.transport.http.QSMethodHandler"/>

        <parameter name="qs.wsdl"

           value="org.apache.axis.transport.http.QSWSDLHandler" />

    </transport>

    <transport name="local">

        <responseFlow>

            <handler type="LocalResponder"/>

        </responseFlow>

    </transport>

</deployment>


 

其中

<servicename="AxisDemo" provider="java:RPC">

        <parametername="allowedMethod" value="*"></parameter>

        <parametername="className"

           value="com.lucky.axis.service.PersonInfoService">

        </parameter>

        <beanMappingqname="myNS:Person" xmlns:myNS="urn:PersonInfo"

           languageSpecificType="java:com.lucky.axis.service.Person"/>

        <beanMappingqname="myNS:Book" xmlns:myNS="urn:PersonBookInfo"

           languageSpecificType="java:com.lucky.axis.service.Book"/>

</service>


是配置服务端的WebService,name="AxisDemo" 是WebService的名称,使用http://localhost:8080/axis/services/AxisDemo?wsdl来访问,name="allowedMethod" 表示服务类中那些方法需要封装,value="*" 表示所有的方法都封装,如果值封装其中部分方法,需要把方法名称列出来,用“,”逗号分割,name="className" 表示定义WebService服务端的类,value="com.lucky.axis.service.PersonInfoService"表示将这个类作为WebService类封装,<beanMapping qname="myNS:Person"xmlns:myNS="urn:PersonInfo"languageSpecificType="java:com.lucky.axis.service.Person" />这个表示类中需要引入的其他类
重新启动Tomcat5.5,访问http://localhost:8080/axis/services/AxisDemo?wsdl,可以看到该Web Service的WSDL描述信息 .

编写客户端测试类,命名为Client.java。在该类中分别对PersonInfoService.java所提供的方法进行调用,代码如下:

package com.lucky.axis.client;

 

import java.util.HashMap;

import java.util.Map;

 

import javax.xml.namespace.QName;

 

importorg.apache.axis.client.Call;

importorg.apache.axis.client.Service;

importorg.apache.axis.encoding.ser.BeanDeserializerFactory;

importorg.apache.axis.encoding.ser.BeanSerializerFactory;

 

import com.lucky.axis.service.Book;

importcom.lucky.axis.service.Person;

 

public class Client {

    public Client() {

    }

 

    public static void main(String[] args)throws Exception {

//        if (args.length < 1) {

//            System.out.println("错误:缺少参数");

//            System.exit(0);

//        }

        // Web服务的URL

        String url ="http://localhost:8080/axis/services/AxisDemo";

        Service service = new Service();

        Call call = (Call)service.createCall();

        call.setTargetEndpointAddress(url);

 

        // 注册序列化/反序列化器

        QName qn = newQName("urn:PersonInfo", "Person");

        call.registerTypeMapping(Person.class,qn, new BeanSerializerFactory(

                Person.class, qn),

                newBeanDeserializerFactory(Person.class, qn));

       QName qnb = newQName("urn:PersonBookInfo", "Book");

        call.registerTypeMapping(Book.class,qnb, new BeanSerializerFactory(

                Book.class, qnb), newBeanDeserializerFactory(Book.class, qnb));

 

        // 设置调用方法

        call.setOperationName(newjavax.xml.namespace.QName("http://test",

                "getPersonInfo"));

        Person person = new Person();

        person.setName("Kiah Han");

        person.setAge(26);

        Map map = new HashMap();

        map.put("NAME", "李彬");

       map.put("YEAR", new Integer(3));

        person.setSkill(map);

        Book book = new Book();

        book.setBookname("<Thinking inJava>");

        book.setIsbn(new Long(123456789));

        book.setPrice((float) 25.98);

        book.setPages(new Integer(925));

        person.setMybook(book);

 

        // Web服务调用

        java.lang.Object _resp =call.invoke(new java.lang.Object[] { person });

 

        // 输出到屏幕

        System.out.println(_resp.toString());

 

        System.out

                .println("------------StartingsetBookInfo()---------------------");

        call.setOperationName(newjavax.xml.namespace.QName("http://test",

                "setBookInfo"));

        java.lang.Object _resbook =call.invoke(new java.lang.Object[] {

                "<Spring pro>", newLong(987654321) });

 

        Book mybook = (Book) _resbook;

 

       System.out.println(mybook.getBookname());

        System.out.println(mybook.getIsbn());

        System.out.println(mybook.getPrice());

        System.out.println(mybook.getPages());

        System.out

                .println("------------EndsetBookInfo()---------------------------");

 

        System.out

               .println("------------StartinggetPersonInfo()---------------------");

        call.setOperationName(newjavax.xml.namespace.QName("http://test",

                "getPersonInfo"));

        java.lang.Object _resperson =call.invoke(new java.lang.Object[] {});

 

        Person aaron = (Person) _resperson;

        System.out.println(aaron.getName());

        System.out.println(aaron.getAge());

        Map skill = aaron.getSkill();

       System.out.println(skill.get("NAME"));

       System.out.println(skill.get("YEAR"));

        Book aaronbook = aaron.getMybook();

        System.out.println(aaronbook.getBookname());

       System.out.println(aaronbook.getIsbn());

       System.out.println(aaronbook.getPrice());

       System.out.println(aaronbook.getPages());

        System.out

                .println("------------EndgetPersonInfo()---------------------");

    }

 

}


直接运行该Client.java中的main方法,运行结果如下:

 

Hello, Kiah Han ! This is you information...
Ages: 26
李彬 : you have 3 years experience!
Book Name : <Thinking in Java>
ISBN : 123456789
You pay $25.98 for this book.
This book have 925 pages.

------------Starting setBookInfo()---------------------
<Spring pro>
987654321
25.65
265
------------End setBookInfo()---------------------------
------------Starting getPersonInfo()---------------------
Aaron
26
JAVA
3
<Thinking in Java>
456256821
99.8
982
------------End getPersonInfo()---------------------


=========================项目实战===========================

再贴一个项目中用到的server-config.wsdd

<?xml version="1.0"encoding="UTF-8"?>

<deploymentname="defaultClientConfig"

xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"

xmlns:handler="http://xml.apache.org/axis/wsdd/providers/handler"xmlns="http://xml.apache.org/axis/wsdd/">

 <globalConfiguration name="defaultClientConfig">

    <requestFlow name="RequestFlow1"type="">

        <handler name="Handler1"type="java:org.apache.axis.handlers.JWSHandler">

          <parameter name="scope"value="session"/>

        </handler>

        <handler name="Handler2"type="java:org.apache.axis.handlers.JWSHandler">

            <parameter name="scope"value="request"/>

            <parametername="extension" value=".jwr"/>

        </handler>

      </requestFlow>

    </globalConfiguration>

    <handler name="URLMapper"type="java:org.apache.axis.handlers.http.URLMapper"/>

    <handler name="LocalResponder"type="java:org.apache.axis.transport.local.LocalResponder"/>

    <handler name="Authenticate"type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>

 

    <transport name="http"type="">

        <requestFlow name="RequestFlow1"type="">

        <handler name="Handler1"type="URLMapper"/>    

        <handler name="Handler2"type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>

      </requestFlow>

    </transport>

    <transport name="local"type="">

        <responseFlowname="ResponseFlow1" type="">

            <handlername="Handler1" type="LocalResponder"/>

        </responseFlow>

    </transport>

 

 <service name="PlmWebService"provider="java:RPC">

    <parameter name="scope"value="Request"/>

    <parameter name="className"value="com.xxx.pms.plmproject.business.pdp_rcs.service.facade.PlmWebService"/>

    <parametername="allowedMethods" value="*"/>

   <namespace>http://pms.eai.xxx.com/</namespace>

 </service>

 

 <service name="MyTestService"provider="java:RPC">

    <parameter name="className"value="com.xxx.eai.pms.soc99.MyTestService"/>

    <parametername="allowedMethods" value="*"/>

   <namespace>http://pms.eai.xxx.com/soc99</namespace>

<!-- 辅助类,具体代码下面贴出 -->

    <beanMappingqname="myNS:Request" xmlns:myNS="urn:soc99.pms.eai.xxx.com"languageSpecificType="java:com.xxx.eai.pms.soc99.Request"/>

    <beanMappingqname="myNS:Response"xmlns:myNS="urn:soc99.pms.eai.xxx.com" languageSpecificType="java:com.xxx.eai.pms.soc99.Response"/>

    <beanMappingqname="myNS:PLMRightData"xmlns:myNS="urn:soc99.pms.eai.xxx.com"languageSpecificType="java:com.xxx.eai.pms.soc99.PLMRightData"/>

    <beanMappingqname="myNS:ErrorCollection" xmlns:myNS="urn:soc99.pms.eai.xxx.com"languageSpecificType="java:com.xxx.eai.pms.soc99.ErrorCollection"/>   

    <beanMappingqname="myNS:InputCollection"xmlns:myNS="urn:soc99.pms.eai.xxx.com"languageSpecificType="java:com.xxx.eai.pms.soc99.InputCollection"/>   

    <beanMappingqname="myNS:OutputCollection"xmlns:myNS="urn:soc99.pms.eai.xxx.com"languageSpecificType="java:com.xxx.eai.pms.soc99.OutputCollection"/>       

    <beanMappingqname="myNS:MsgHeader"xmlns:myNS="urn:soc99.pms.eai.xxx.com" languageSpecificType="java:com.xxx.eai.pms.soc99.MsgHeader"/>       

 </service>

 

  <globalConfiguration>

    <parametername="sendMultiRefs" value="true" />

    <parametername="disablePrettyXML" value="true" />

    <parametername="adminPassword" value="admin" />

    <parametername="dotNetSoapEncFix" value="true" />

    <parametername="enableNamespacePrefixOptimization" value="false"/>

    <parametername="sendXMLDeclaration" value="true" />

    <parameter name="sendXsiTypes"value="true" />

    <parameter name="attachments.implementation"

     value="org.apache.axis.attachments.AttachmentsImpl" />

    <requestFlow>

      <handlertype="java:org.apache.axis.handlers.JWSHandler">

        <parameter name="scope"value="session" />

      </handler>

      <handlertype="java:org.apache.axis.handlers.JWSHandler">

        <parameter name="scope"value="request" />

        <parametername="extension" value=".jwr" />

      </handler>

    </requestFlow>

 </globalConfiguration>

 

 

 <handler name="URLMapper"

    type="java:org.apache.axis.handlers.http.URLMapper"/>

 <handler name="LocalResponder"

   type="java:org.apache.axis.transport.local.LocalResponder"/>

 <handler name="Authenticate"

   type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>

 <service name="AdminService"provider="java:MSG">

    <parametername="allowedMethods" value="AdminService" />

    <parametername="enableRemoteAdmin" value="false" />

    <parameter name="className"value="org.apache.axis.utils.Admin" />

    <namespace>http://xml.apache.org/axis/wsdd/</namespace>

 </service>

 

 <service name="Version" provider="java:RPC">

    <parametername="allowedMethods" value="getVersion" />

    <parameter name="className"value="org.apache.axis.Version" />

 </service>

 

 

 

 <transport name="http">

    <requestFlow>

      <handler type="URLMapper"/>

      <handler

       type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>

    </requestFlow>

    <parameter name="qs:list"

     value="org.apache.axis.transport.http.QSListHandler" />

    <parameter name="qs:wsdl"

     value="org.apache.axis.transport.http.QSWSDLHandler" />

    <parameter name="qs.list"

     value="org.apache.axis.transport.http.QSListHandler" />

    <parameter name="qs.method"

      value="org.apache.axis.transport.http.QSMethodHandler"/>

    <parameter name="qs:method"

     value="org.apache.axis.transport.http.QSMethodHandler" />

    <parameter name="qs.wsdl"

     value="org.apache.axis.transport.http.QSWSDLHandler" />

 </transport>

 <transport name="local">

    <responseFlow>

      <handlertype="LocalResponder" />

    </responseFlow>

 </transport>

 

 

</deployment>

 

输入参数格式:

输入参数格式:

<MsgSend><MsgHeader><SourceSystemID>SECID-SOCID</SourceSystemID><SourceSystemName>SEC-SOC</SourceSystemName><UserID></UserID><UserName></UserName><SubmitDate>2011-02-2014:49:54</SubmitDate></MsgHeader><MsgBody><ServiceCode>sys0001</ServiceCode><MsgId>100</MsgId><BizCont><msgtype>msg001</msgtype><syscode>610011</syscode><closeduser>1324564</closeduser><optuser>5542211</optuser></BizCont></MsgBody></MsgSend>


 


=============================辅助类================================


错误集合:

public class ErrorCollection  implements java.io.Serializable {

    private java.lang.String entityName;

 

    private java.lang.String errorMessage;

 

    public ErrorCollection() {

    }

 

    public ErrorCollection(

           java.lang.String entityName,

           java.lang.String errorMessage) {

           this.entityName = entityName;

           this.errorMessage = errorMessage;

    }

 

 

    /**

     * Gets the entityName value for thisErrorCollection.

     *

     * @return entityName

     */

    public java.lang.String getEntityName() {

        return entityName;

    }

 

 

    /**

     * Sets the entityName value for thisErrorCollection.

     *

     * @param entityName

     */

    public void setEntityName(java.lang.StringentityName) {

        this.entityName = entityName;

    }

 

 

    /**

     * Gets the errorMessage value for thisErrorCollection.

     *

    * @return errorMessage

     */

    public java.lang.String getErrorMessage() {

        return errorMessage;

    }

 

 

    /**

     * Sets the errorMessage value for thisErrorCollection.

     *

     * @param errorMessage

     */

    public void setErrorMessage(java.lang.StringerrorMessage) {

        this.errorMessage = errorMessage;

    }

 

    private java.lang.Object __equalsCalc =null;

    public synchronized booleanequals(java.lang.Object obj) {

        if (!(obj instanceof ErrorCollection))return false;

        ErrorCollection other =(ErrorCollection) obj;

        if (obj == null) return false;

        if (this == obj) return true;

        if (__equalsCalc != null) {

            return (__equalsCalc == obj);

        }

        __equalsCalc = obj;

        boolean _equals;

        _equals = true &&

            ((this.entityName==null &&other.getEntityName()==null) ||

             (this.entityName!=null &&

             this.entityName.equals(other.getEntityName()))) &&

            ((this.errorMessage==null&& other.getErrorMessage()==null) ||

             (this.errorMessage!=null&&

             this.errorMessage.equals(other.getErrorMessage())));

        __equalsCalc = null;

        return _equals;

   }

 

    private boolean __hashCodeCalc = false;

    public synchronized int hashCode() {

        if (__hashCodeCalc) {

            return 0;

        }

        __hashCodeCalc = true;

        int _hashCode = 1;

        if (getEntityName() != null) {

            _hashCode += getEntityName().hashCode();

        }

        if (getErrorMessage() != null) {

            _hashCode +=getErrorMessage().hashCode();

        }

        __hashCodeCalc = false;

        return _hashCode;

    }

 

    // Type metadata

    private staticorg.apache.axis.description.TypeDesc typeDesc =

        neworg.apache.axis.description.TypeDesc(ErrorCollection.class, true);

 

    static {

        typeDesc.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","ErrorCollection"));

        org.apache.axis.description.ElementDescelemField = new org.apache.axis.description.ElementDesc();

       elemField.setFieldName("entityName");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "entityName"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

        elemField.setFieldName("errorMessage");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "errorMessage"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

    }

 

    /**

     * Return type metadata object

     */

    public staticorg.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

 

    /**

     * Get Custom Serializer

     */

    public staticorg.apache.axis.encoding.Serializer getSerializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanSerializer(

            _javaType, _xmlType, typeDesc);

    }

 

    /**

     * Get Custom Deserializer

     */

    public staticorg.apache.axis.encoding.Deserializer getDeserializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanDeserializer(

            _javaType, _xmlType, typeDesc);

    }

 

}


输入参数封装类:

public class InputCollection  implements java.io.Serializable {

    private java.lang.String closeduser;

 

    private java.lang.String msgtype;

 

    private java.lang.String optuser;

 

    private java.lang.String syscode;

 

    public InputCollection() {

    }

 

    public InputCollection(

           java.lang.String closeduser,

           java.lang.String msgtype,

           java.lang.String optuser,

           java.lang.String syscode) {

           this.closeduser = closeduser;

           this.msgtype = msgtype;

           this.optuser = optuser;

           this.syscode = syscode;

    }

 

 

    /**

     * Gets the closeduser value for thisInputCollection.

     *

     * @return closeduser

     */

    public java.lang.String getCloseduser() {

        return closeduser;

    }

 

 

    /**

     *Sets the closeduser value for this InputCollection.

     *

     * @param closeduser

     */

    public void setCloseduser(java.lang.Stringcloseduser) {

        this.closeduser = closeduser;

    }

 

 

    /**

     * Gets the msgtype value for this InputCollection.

     *

     * @return msgtype

     */

    public java.lang.String getMsgtype() {

        return msgtype;

    }

 

 

    /**

     * Sets the msgtype value for thisInputCollection.

     *

     * @param msgtype

     */

    public void setMsgtype(java.lang.Stringmsgtype) {

        this.msgtype = msgtype;

    }

 

 

    /**

     * Gets the optuser value for thisInputCollection.

     *

     * @return optuser

     */

    public java.lang.String getOptuser() {

        return optuser;

    }

 

 

    /**

     * Sets the optuser value for thisInputCollection.

     *

     * @param optuser

     */

    public void setOptuser(java.lang.Stringoptuser) {

        this.optuser = optuser;

    }

 

 

    /**

     * Gets the syscode value for thisInputCollection.

     *

     * @return syscode

     */

    public java.lang.String getSyscode() {

        return syscode;

    }

 

 

    /**

     * Sets the syscode value for thisInputCollection.

     *

     * @param syscode

     */

    public void setSyscode(java.lang.Stringsyscode) {

        this.syscode = syscode;

    }

 

    private java.lang.Object __equalsCalc =null;

    public synchronized booleanequals(java.lang.Object obj) {

        if (!(obj instanceof InputCollection))return false;

        InputCollection other =(InputCollection) obj;

        if (obj == null) return false;

        if (this == obj) return true;

        if (__equalsCalc != null) {

            return (__equalsCalc == obj);

        }

        __equalsCalc = obj;

        boolean _equals;

        _equals = true &&

            ((this.closeduser==null &&other.getCloseduser()==null) ||

             (this.closeduser!=null &&

             this.closeduser.equals(other.getCloseduser()))) &&

            ((this.msgtype==null &&other.getMsgtype()==null) ||

             (this.msgtype!=null &&

             this.msgtype.equals(other.getMsgtype()))) &&

            ((this.optuser==null &&other.getOptuser()==null) ||

             (this.optuser!=null &&

              this.optuser.equals(other.getOptuser())))&&

            ((this.syscode==null &&other.getSyscode()==null) ||

             (this.syscode!=null &&

             this.syscode.equals(other.getSyscode())));

        __equalsCalc = null;

        return _equals;

    }

 

    private boolean __hashCodeCalc = false;

    public synchronized int hashCode() {

        if (__hashCodeCalc) {

            return 0;

        }

        __hashCodeCalc = true;

        int _hashCode = 1;

        if (getCloseduser() != null) {

            _hashCode +=getCloseduser().hashCode();

        }

        if (getMsgtype() != null) {

            _hashCode +=getMsgtype().hashCode();

        }

        if (getOptuser() != null) {

            _hashCode +=getOptuser().hashCode();

        }

        if (getSyscode() != null) {

            _hashCode +=getSyscode().hashCode();

        }

        __hashCodeCalc = false;

        return _hashCode;

    }

 

    // Type metadata

    private staticorg.apache.axis.description.TypeDesc typeDesc =

       neworg.apache.axis.description.TypeDesc(InputCollection.class, true);

 

    static {

        typeDesc.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","InputCollection"));

        org.apache.axis.description.ElementDescelemField = new org.apache.axis.description.ElementDesc();

       elemField.setFieldName("closeduser");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "closeduser"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("msgtype");

        elemField.setXmlName(new javax.xml.namespace.QName("","msgtype"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("optuser");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "optuser"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("syscode");

        elemField.setXmlName(new javax.xml.namespace.QName("","syscode"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

    }

 

    /**

     * Return type metadata object

     */

    public staticorg.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

 

    /**

     * Get Custom Serializer

     */

    public staticorg.apache.axis.encoding.Serializer getSerializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanSerializer(

            _javaType, _xmlType, typeDesc);

    }

 

    /**

     * Get Custom Deserializer

     */

    public staticorg.apache.axis.encoding.Deserializer getDeserializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanDeserializer(

            _javaType, _xmlType, typeDesc);

    }

 

}


xml发送头类:

public class MsgHeader  implements java.io.Serializable {

    private java.lang.String sourceSystemId;

 

    private java.lang.String sourceSystemName;

 

    private java.util.Calendar submitDate;

 

    private java.lang.String userId;

 

    private java.lang.String userName;

 

    public MsgHeader() {

    }

 

    public MsgHeader(

           java.lang.String sourceSystemId,

           java.lang.String sourceSystemName,

           java.util.Calendar submitDate,

           java.lang.String userId,

           java.lang.String userName) {

           this.sourceSystemId =sourceSystemId;

           this.sourceSystemName =sourceSystemName;

          this.submitDate = submitDate;

           this.userId = userId;

           this.userName = userName;

    }

 

 

    /**

     * Gets the sourceSystemId value for thisMsgHeader.

     *

     * @return sourceSystemId

     */

    public java.lang.String getSourceSystemId(){

        return sourceSystemId;

    }

 

 

    /**

     * Sets the sourceSystemId value for thisMsgHeader.

     *

     * @param sourceSystemId

     */

    public voidsetSourceSystemId(java.lang.String sourceSystemId) {

        this.sourceSystemId = sourceSystemId;

    }

 

 

    /**

     * Gets the sourceSystemName value for thisMsgHeader.

     *

     * @return sourceSystemName

     */

    public java.lang.StringgetSourceSystemName() {

        return sourceSystemName;

    }

 

 

   /**

     * Sets the sourceSystemName value for thisMsgHeader.

     *

     * @param sourceSystemName

     */

    public voidsetSourceSystemName(java.lang.String sourceSystemName) {

        this.sourceSystemName =sourceSystemName;

    }

 

 

    /**

     * Gets the submitDate value for thisMsgHeader.

     *

     * @return submitDate

     */

    public java.util.Calendar getSubmitDate() {

        return submitDate;

    }

 

 

    /**

     * Sets the submitDate value for thisMsgHeader.

     *

     * @param submitDate

     */

    public voidsetSubmitDate(java.util.Calendar submitDate) {

        this.submitDate = submitDate;

    }

 

 

    /**

     * Gets the userId value for thisMsgHeader.

     *

     * @return userId

     */

    public java.lang.String getUserId() {

        return userId;

    }

 

 

    /**

     * Sets the userId value for thisMsgHeader.

     *

     * @param userId

     */

    public void setUserId(java.lang.StringuserId) {

        this.userId = userId;

    }

 

 

    /**

     * Gets the userName value for thisMsgHeader.

     *

     * @return userName

     */

    public java.lang.String getUserName() {

        return userName;

    }

 

 

    /**

     * Sets the userName value for thisMsgHeader.

     *

     * @param userName

    */

    public void setUserName(java.lang.StringuserName) {

        this.userName = userName;

    }

 

    private java.lang.Object __equalsCalc =null;

    public synchronized booleanequals(java.lang.Object obj) {

        if (!(obj instanceof MsgHeader)) returnfalse;

        MsgHeader other = (MsgHeader) obj;

        if (obj == null) return false;

        if (this == obj) return true;

        if (__equalsCalc != null) {

            return (__equalsCalc == obj);

        }

       __equalsCalc = obj;

        boolean _equals;

        _equals = true &&

            ((this.sourceSystemId==null&& other.getSourceSystemId()==null) ||

             (this.sourceSystemId!=null&&

             this.sourceSystemId.equals(other.getSourceSystemId()))) &&

            ((this.sourceSystemName==null&& other.getSourceSystemName()==null) ||

             (this.sourceSystemName!=null&&

             this.sourceSystemName.equals(other.getSourceSystemName()))) &&

            ((this.submitDate==null &&other.getSubmitDate()==null) ||

             (this.submitDate!=null &&

             this.submitDate.equals(other.getSubmitDate()))) &&

            ((this.userId==null &&other.getUserId()==null) ||

             (this.userId!=null &&

              this.userId.equals(other.getUserId())))&&

            ((this.userName==null &&other.getUserName()==null) ||

             (this.userName!=null &&

             this.userName.equals(other.getUserName())));

        __equalsCalc = null;

        return _equals;

    }

 

    private boolean __hashCodeCalc = false;

    public synchronized int hashCode() {

        if (__hashCodeCalc) {

            return 0;

        }

        __hashCodeCalc = true;

        int _hashCode = 1;

        if (getSourceSystemId() != null) {

            _hashCode +=getSourceSystemId().hashCode();

        }

        if (getSourceSystemName() != null) {

            _hashCode +=getSourceSystemName().hashCode();

        }

        if (getSubmitDate() != null) {

            _hashCode +=getSubmitDate().hashCode();

        }

        if (getUserId() != null) {

            _hashCode +=getUserId().hashCode();

        }

        if (getUserName() != null) {

            _hashCode +=getUserName().hashCode();

        }

        __hashCodeCalc = false;

        return _hashCode;

    }

 

    // Type metadata

    private staticorg.apache.axis.description.TypeDesc typeDesc =

        neworg.apache.axis.description.TypeDesc(MsgHeader.class, true);

 

    static {

        typeDesc.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","MsgHeader"));

        org.apache.axis.description.ElementDescelemField = new org.apache.axis.description.ElementDesc();

       elemField.setFieldName("sourceSystemId");

       elemField.setXmlName(newjavax.xml.namespace.QName("", "sourceSystemId"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("sourceSystemName");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "sourceSystemName"));

        elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("submitDate");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "submitDate"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","dateTime"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("userId");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "userId"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("userName");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "userName"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

    }

 

    /**

     * Return type metadata object

     */

    public staticorg.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

 

    /**

     * Get Custom Serializer

     */

    public staticorg.apache.axis.encoding.Serializer getSerializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanSerializer(

            _javaType, _xmlType, typeDesc);

    }

 

    /**

     * Get Custom Deserializer

     */

    public staticorg.apache.axis.encoding.Deserializer getDeserializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanDeserializer(

            _javaType, _xmlType, typeDesc);

    }

 

}


返回值类:

public classOutputCollection  implementsjava.io.Serializable {

    private java.lang.String processReturn;

 

    public OutputCollection() {

    }

 

    public OutputCollection(

           java.lang.String processReturn) {

           this.processReturn = processReturn;

    }

 

 

    /**

     * Gets the processReturn value for thisOutputCollection.

     *

     * @return processReturn

     */

    public java.lang.String getProcessReturn(){

        return processReturn;

    }

 

 

    /**

     * Sets the processReturn value for thisOutputCollection.

     *

     * @param processReturn

     */

    public voidsetProcessReturn(java.lang.String processReturn) {

        this.processReturn = processReturn;

    }

 

    private java.lang.Object __equalsCalc =null;

    public synchronized booleanequals(java.lang.Object obj) {

        if (!(obj instanceof OutputCollection))return false;

        OutputCollection other =(OutputCollection) obj;

        if (obj == null) return false;

        if (this == obj) return true;

        if (__equalsCalc != null) {

            return (__equalsCalc == obj);

       }

        __equalsCalc = obj;

        boolean _equals;

        _equals = true &&

            ((this.processReturn==null&& other.getProcessReturn()==null) ||

             (this.processReturn!=null&&

              this.processReturn.equals(other.getProcessReturn())));

        __equalsCalc = null;

        return _equals;

    }

 

    private boolean __hashCodeCalc = false;

    public synchronized int hashCode() {

        if (__hashCodeCalc) {

            return 0;

        }

        __hashCodeCalc = true;

        int _hashCode = 1;

        if (getProcessReturn() != null) {

            _hashCode +=getProcessReturn().hashCode();

        }

        __hashCodeCalc = false;

        return _hashCode;

    }

 

    // Type metadata

    private staticorg.apache.axis.description.TypeDesc typeDesc =

        neworg.apache.axis.description.TypeDesc(OutputCollection.class, true);

 

    static {

        typeDesc.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com", "OutputCollection"));

        org.apache.axis.description.ElementDescelemField = new org.apache.axis.description.ElementDesc();

       elemField.setFieldName("processReturn");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "processReturn"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

    }

 

    /**

     * Return type metadata object

     */

    public staticorg.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

 

    /**

     * Get Custom Serializer

     */

    public staticorg.apache.axis.encoding.Serializer getSerializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanSerializer(

            _javaType, _xmlType, typeDesc);

    }

 

    /**

     * Get Custom Deserializer

     */

    public staticorg.apache.axis.encoding.Deserializer getDeserializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanDeserializer(

            _javaType, _xmlType, typeDesc);

    }

 

}



public class PLMRightData {

       

    private long userId; // 用户id

 

    private String userNo; // 12位电脑号

 

        privateString userName; // 用户名

 

        privateString submitDate; //提交时间

       

        privateString syscode; //系统编号

 

    private int serviceCode; // 服务器ID

 

    private String msgType; // 操作类型(消息操作类型)

   

    private String optuser; //审核人工号

         

    public long getUserId() {

               returnuserId;

        }

 

        publicvoid setUserId(long userId) {

               this.userId= userId;

        }

 

        publicString getUserName() {

               returnuserName;

        }

 

        publicvoid setUserName(String userName) {

               this.userName= userName;

        }

 

        publicString getSubmitDate() {

               returnsubmitDate;

        }

 

        publicvoid setSubmitDate(String submitDate) {

               this.submitDate= submitDate;

        }

 

        publicString getSyscode() {

               returnsyscode;

        }

 

        publicvoid setSyscode(String syscode) {

               this.syscode= syscode;

        }

 

    public int getServiceCode() {

               returnserviceCode;

        }

 

        publicvoid setServiceCode(int serviceCode) {

               this.serviceCode= serviceCode;

        }

 

        publicString getUserNo() {

               returnuserNo;

        }

 

        publicvoid setUserNo(String userNo) {

               this.userNo= userNo;

        }

       

    public String getMsgType() {

               returnmsgType;

        }

 

        publicvoid setMsgType(String msgType) {

               this.msgType= msgType;

        }

 

        publicString getOptuser() {

               returnoptuser;

        }

 

        publicvoid setOptuser(String optuser) {

               this.optuser= optuser;

        }

}

 

web service 调用接口类:

 

public class MyTestService

{

    //获取基础信息PLMRightService接口服务

    private PLMRightService PLMRightService=(PLMRightService)SSBBus.findDomainService("PLMRightService");

    /**

     * 获取当前登陆用户的PMS任务

     * @param request

     * @return

     * @throws Exception

     */

    public Response closeAuthRight(Requestrequest) throws Exception

    {

        Response response=new Response();

        //输入数据接收

        String closeduser =request.getInputCollection().getCloseduser();

        String msgtype =request.getInputCollection().getMsgtype();

        String optuser =request.getInputCollection().getOptuser();

        String syscode =request.getInputCollection().getSyscode();

       

        //处理请求头

        //用户效验

        OutputCollection outputs=newOutputCollection();

        ErrorCollection errors=newErrorCollection();

       

        if(null == closeduser ||"".equals(closeduser))

        {

            errors.setEntityName("被关闭工号不能为空");

           response.setProcessStatus("0001");

           outputs.setProcessReturn("0001");

            response.setErrors(errors);

            response.setOutputs(outputs);           

            return response;

        }

       

        if(null == msgtype ||"".equals(msgtype))

        {

            errors.setEntityName("消息类型不能为空");

           response.setProcessStatus("0001");

           outputs.setProcessReturn("0001");

            response.setErrors(errors);

            response.setOutputs(outputs);           

            return response;

       }

       

        if(null == optuser ||"".equals(optuser))

        {

            errors.setEntityName("审核人工号不能为空");

           response.setProcessStatus("0001");

           outputs.setProcessReturn("0001");

            response.setErrors(errors);

            response.setOutputs(outputs);           

            return response;

        }

       

        if(null == syscode ||"".equals(syscode))

        {

            errors.setEntityName("系统编号不能为空");

           response.setProcessStatus("0001");

           outputs.setProcessReturn("0001");

            response.setErrors(errors);

            response.setOutputs(outputs);           

            return response;

        }

        

        PLMRightData prd = new PLMRightData();

        List<PLMRightData> list = newArrayList();

       

        prd.setMsgType(msgtype);

        prd.setOptuser(optuser);

        prd.setUserNo(closeduser);

        prd.setSyscode(syscode);

       

        list.add(prd);

       

        boolean flag = PLMRightService.deleteAllUserAuthority(list);

       

       if(flag&&(errors.getEntityName()==null ||"".equals(errors.getEntityName())))

        {

               response.setProcessStatus("0000");

               outputs.setProcessReturn("0000");

        }

        else

        {

            errors.setEntityName("权限关闭失败");

           response.setProcessStatus("0001");

           outputs.setProcessReturn("0001");

        }       

 

        response.setErrors(errors);

        response.setOutputs(outputs);

       

        return response;

    }

}



public class Request  implements java.io.Serializable {

    private com.xxx.eai.pms.soc99.InputCollectioninputCollection;

 

    private com.xxx.eai.pms.soc99.MsgHeadermsgHeader;

 

    public Request() {

    }

 

    public Request(

           com.xxx.eai.pms.soc99.InputCollectioninputCollection,

           com.xxx.eai.pms.soc99.MsgHeadermsgHeader) {

           this.inputCollection =inputCollection;

           this.msgHeader = msgHeader;

    }

 

 

    /**

     * Gets the inputCollection value for thisRequest.

     *

     * @return inputCollection

     */

    public com.xxx.eai.pms.soc99.InputCollectiongetInputCollection() {

        return inputCollection;

    }

 

 

    /**

     * Sets the inputCollection value for thisRequest.

     *

     * @param inputCollection

     */

    public void setInputCollection(com.xxx.eai.pms.soc99.InputCollectioninputCollection) {

        this.inputCollection = inputCollection;

    }

 

 

    /**

     * Gets the msgHeader value for thisRequest.

     *

     * @return msgHeader

     */

    public com.xxx.eai.pms.soc99.MsgHeadergetMsgHeader() {

        return msgHeader;

    }

 

 

    /**

     * Sets the msgHeader value for thisRequest.

     *

     * @param msgHeader

     */

    public void setMsgHeader(com.xxx.eai.pms.soc99.MsgHeadermsgHeader) {

        this.msgHeader = msgHeader;

    }

 

    private java.lang.Object __equalsCalc =null;

    public synchronized booleanequals(java.lang.Object obj) {

        if (!(obj instanceof Request)) returnfalse;

        Request other = (Request) obj;

        if (obj == null) return false;

        if (this == obj) return true;

        if (__equalsCalc != null) {

            return (__equalsCalc == obj);

        }

        __equalsCalc = obj;

       boolean _equals;

        _equals = true &&

            ((this.inputCollection==null&& other.getInputCollection()==null) ||

             (this.inputCollection!=null&&

             this.inputCollection.equals(other.getInputCollection()))) &&

            ((this.msgHeader==null &&other.getMsgHeader()==null) ||

             (this.msgHeader!=null &&

             this.msgHeader.equals(other.getMsgHeader())));

        __equalsCalc = null;

        return _equals;

    }

 

    private boolean __hashCodeCalc = false;

    public synchronized int hashCode() {

        if (__hashCodeCalc) {

            return 0;

        }

        __hashCodeCalc = true;

        int _hashCode = 1;

        if (getInputCollection() != null) {

            _hashCode += getInputCollection().hashCode();

        }

        if (getMsgHeader() != null) {

            _hashCode +=getMsgHeader().hashCode();

        }

        __hashCodeCalc = false;

        return _hashCode;

    }

 

    // Type metadata

    private staticorg.apache.axis.description.TypeDesc typeDesc =

        neworg.apache.axis.description.TypeDesc(Request.class, true);

 

    static {

        typeDesc.setXmlType(newjavax.xml.namespace.QName("urn:soc99.pms.eai.xxx.com","Request"));

        org.apache.axis.description.ElementDescelemField = new org.apache.axis.description.ElementDesc();

       elemField.setFieldName("inputCollection");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "inputCollection"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","InputCollection"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

        elemField.setFieldName("msgHeader");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "msgHeader"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","MsgHeader"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

    }

 

    /**

     * Return type metadata object

     */

    public staticorg.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

 

    /**

     * Get Custom Serializer

     */

    public static org.apache.axis.encoding.SerializergetSerializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanSerializer(

           _javaType, _xmlType, typeDesc);

    }

 

    /**

     * Get Custom Deserializer

     */

    public staticorg.apache.axis.encoding.Deserializer getDeserializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType) {

        return

          new org.apache.axis.encoding.ser.BeanDeserializer(

            _javaType, _xmlType, typeDesc);

    }

 

}

 

后面是2个辅助类:

public class Request  implements java.io.Serializable {

    private com.xxx.eai.pms.soc99.InputCollectioninputCollection;

 

    private com.xxx.eai.pms.soc99.MsgHeadermsgHeader;

 

    public Request() {

    }

 

    public Request(

          com.xxx.eai.pms.soc99.InputCollection inputCollection,

           com.xxx.eai.pms.soc99.MsgHeadermsgHeader) {

           this.inputCollection =inputCollection;

           this.msgHeader = msgHeader;

    }

 

 

    /**

     * Gets the inputCollection value for thisRequest.

     *

     * @return inputCollection

     */

   public com.xxx.eai.pms.soc99.InputCollectiongetInputCollection() {

        return inputCollection;

    }

 

 

    /**

     * Sets the inputCollection value for thisRequest.

     *

     * @param inputCollection

     */

    public void setInputCollection(com.xxx.eai.pms.soc99.InputCollectioninputCollection) {

        this.inputCollection = inputCollection;

    }

 

 

    /**

     * Gets the msgHeader value for thisRequest.

     *

     * @return msgHeader

     */

    public com.xxx.eai.pms.soc99.MsgHeadergetMsgHeader() {

        return msgHeader;

    }

 

 

    /**

     * Sets the msgHeader value for thisRequest.

     *

     * @param msgHeader

     */

    public void setMsgHeader(com.xxx.eai.pms.soc99.MsgHeadermsgHeader) {

        this.msgHeader = msgHeader;

    }

 

    private java.lang.Object __equalsCalc =null;

    public synchronized booleanequals(java.lang.Object obj) {

        if (!(obj instanceof Request)) returnfalse;

        Request other = (Request) obj;

       if (obj == null) returnfalse;

        if (this == obj) return true;

        if (__equalsCalc != null) {

            return (__equalsCalc == obj);

        }

        __equalsCalc = obj;

        boolean _equals;

        _equals = true &&

            ((this.inputCollection==null&& other.getInputCollection()==null) ||

             (this.inputCollection!=null&&

             this.inputCollection.equals(other.getInputCollection()))) &&

            ((this.msgHeader==null &&other.getMsgHeader()==null) ||

             (this.msgHeader!=null &&

             this.msgHeader.equals(other.getMsgHeader())));

        __equalsCalc = null;

        return _equals;

    }

 

    private boolean __hashCodeCalc = false;

    public synchronized int hashCode() {

        if (__hashCodeCalc) {

            return 0;

        }

        __hashCodeCalc = true;

        int _hashCode = 1;

        if (getInputCollection() != null) {

            _hashCode +=getInputCollection().hashCode();

        }

        if (getMsgHeader() != null) {

            _hashCode +=getMsgHeader().hashCode();

        }

        __hashCodeCalc = false;

        return _hashCode;

    }

 

    // Type metadata

    private staticorg.apache.axis.description.TypeDesc typeDesc =

        new org.apache.axis.description.TypeDesc(Request.class,true);

 

    static {

        typeDesc.setXmlType(newjavax.xml.namespace.QName("urn:soc99.pms.eai.xxx.com","Request"));

        org.apache.axis.description.ElementDescelemField = new org.apache.axis.description.ElementDesc();

       elemField.setFieldName("inputCollection");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "inputCollection"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","InputCollection"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("msgHeader");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "msgHeader"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","MsgHeader"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

    }

 

    /**

     * Return type metadata object

     */

    public staticorg.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

 

    /**

     * Get Custom Serializer

     */

    public staticorg.apache.axis.encoding.Serializer getSerializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanSerializer(

            _javaType, _xmlType, typeDesc);

    }

 

    /**

     * Get Custom Deserializer

     */

   public staticorg.apache.axis.encoding.Deserializer getDeserializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanDeserializer(

            _javaType, _xmlType, typeDesc);

    }

 

}

 

 

public class Response  implements java.io.Serializable {

    privatecom.xxx.eai.pms.soc99.ErrorCollection errors;

 

    privatecom.xxx.eai.pms.soc99.OutputCollection outputs;

 

   private java.lang.StringprocessStatus;

 

    public Response() {

    }

 

    public Response(

          com.xxx.eai.pms.soc99.ErrorCollection errors,

          com.xxx.eai.pms.soc99.OutputCollection outputs,

           java.lang.String processStatus) {

           this.errors = errors;

           this.outputs = outputs;

           this.processStatus = processStatus;

    }

 

 

    /**

     * Gets the errors value for this Response.

     *

     * @return errors

     */

    public com.xxx.eai.pms.soc99.ErrorCollectiongetErrors() {

        return errors;

    }

 

 

    /**

     * Sets the errors value for this Response.

     *

     * @param errors

     */

    public void setErrors(com.xxx.eai.pms.soc99.ErrorCollectionerrors) {

        this.errors = errors;

    }

 

 

    /**

     * Gets the outputs value for thisResponse.

     *

     * @return outputs

     */

    public com.xxx.eai.pms.soc99.OutputCollectiongetOutputs() {

        return outputs;

    }

 

 

    /**

     * Sets the outputs value for thisResponse.

    *

     * @param outputs

     */

    public void setOutputs(com.xxx.eai.pms.soc99.OutputCollectionoutputs) {

        this.outputs = outputs;

    }

 

 

    /**

     * Gets the processStatus value for thisResponse.

     *

     * @return processStatus

    */

    public java.lang.String getProcessStatus(){

        return processStatus;

    }

 

 

    /**

     * Sets the processStatus value for thisResponse.

     *

     * @param processStatus

     */

    public voidsetProcessStatus(java.lang.String processStatus) {

        this.processStatus = processStatus;

    }

 

    private java.lang.Object __equalsCalc =null;

    public synchronized booleanequals(java.lang.Object obj) {

        if (!(obj instanceof Response)) returnfalse;

        Response other = (Response) obj;

        if (obj == null) return false;

        if (this == obj) return true;

        if (__equalsCalc != null) {

            return (__equalsCalc == obj);

        }

        __equalsCalc = obj;

        boolean _equals;

        _equals = true &&

            ((this.errors==null &&other.getErrors()==null) ||

             (this.errors!=null &&

             this.errors.equals(other.getErrors()))) &&

            ((this.outputs==null && other.getOutputs()==null)||

             (this.outputs!=null &&

             this.outputs.equals(other.getOutputs()))) &&

            ((this.processStatus==null&& other.getProcessStatus()==null) ||

             (this.processStatus!=null&&

              this.processStatus.equals(other.getProcessStatus())));

        __equalsCalc = null;

        return _equals;

    }

 

    private boolean __hashCodeCalc = false;

    public synchronized int hashCode() {

        if (__hashCodeCalc) {

            return 0;

        }

        __hashCodeCalc = true;

        int _hashCode = 1;

        if (getErrors() != null) {

            _hashCode +=getErrors().hashCode();

        }

        if (getOutputs() != null) {

            _hashCode +=getOutputs().hashCode();

        }

        if (getProcessStatus() != null) {

            _hashCode +=getProcessStatus().hashCode();

        }

        __hashCodeCalc = false;

        return _hashCode;

    }

 

    // Type metadata

    private staticorg.apache.axis.description.TypeDesc typeDesc =

        neworg.apache.axis.description.TypeDesc(Response.class, true);

 

    static {

        typeDesc.setXmlType(newjavax.xml.namespace.QName("urn:soc99.pms.eai.xxx.com","Response"));

        org.apache.axis.description.ElementDescelemField = new org.apache.axis.description.ElementDesc();

       elemField.setFieldName("errors");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "errors"));

        elemField.setXmlType(new javax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","ErrorCollection"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

        elemField.setFieldName("outputs");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "outputs"));

        elemField.setXmlType(newjavax.xml.namespace.QName("http://soc99.pms.eai.xxx.com","OutputCollection"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

        elemField = neworg.apache.axis.description.ElementDesc();

       elemField.setFieldName("processStatus");

        elemField.setXmlName(newjavax.xml.namespace.QName("", "processStatus"));

        elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));

        elemField.setNillable(true);

        typeDesc.addFieldDesc(elemField);

    }

 

    /**

     * Return type metadata object

     */

    public staticorg.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

 

    /**

     * Get Custom Serializer

     */

    public staticorg.apache.axis.encoding.Serializer getSerializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanSerializer(

            _javaType, _xmlType, typeDesc);

    }

 

    /**

     * Get Custom Deserializer

     */

    public staticorg.apache.axis.encoding.Deserializer getDeserializer(

           java.lang.String mechType,

           java.lang.Class _javaType, 

           javax.xml.namespace.QName _xmlType){

        return

          new org.apache.axis.encoding.ser.BeanDeserializer(

            _javaType, _xmlType, typeDesc);

    }

 

}

 

 

这些类都是web service 的辅助类...

 

配置好后重启tomcat,这样就可以将web service 发布了

 

 

测试web service

接下来就是测试web service 了,在eclipse下新建一个java工程,随便什么名字都行,然后在这个java项目处右键新建一个web service client,链接地址那里填写你发布后的wsdl地址,就是打开发布后文件后出现wsdl描述的那个url,然后next就可以了,接下来项目里面会自动生成web service所用到的类和调用接口,可以再写一个测试类,例如:

 

public class TestService {


	public static void main(String[] args) throws AxisFault, ServiceException {
	    Request request = new Request();
	    InputCollection inputCollection = new InputCollection();
	    
	    inputCollection.setCloseduser("10027909");
	    inputCollection.setMsgtype("msg001");
	    inputCollection.setOptuser("10059356");
	    inputCollection.setSyscode("610011");
	    
	    
	    request.setInputCollection(inputCollection);
	    
	    MyTestServiceService service = new MyTestServiceServiceLocator();
	    MyTestService s = service.getMyTestService();
	    try
	    {			
	    	Response response = s.closeAuthRight(request);
	    	String message = response.getProcessStatus();

	    	System.out.println(message);
			
		}
	    catch (Exception e) 
	    {
			e.printStackTrace();
		}

	}
}


这样就可以自己对web service 有效测试了.

 

  •  

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值