关于SOAP调用返回对象的写法 wsdl webservice

关于SOAP调用返回对象的写法 wsdl webservice

//调用部分

import java.net.URL;

 

import javax.xml.namespace.QName;

import javax.xml.rpc.ParameterMode;

import javax.xml.rpc.encoding.SerializerFactory;

import javax.xml.rpc.encoding.TypeMapping;

import javax.xml.rpc.encoding.TypeMappingRegistry;

 

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.encoding.XMLType;

import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;

import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;

 

import org.apache.axis.message.SOAPHeaderElement;

import javax.xml.soap.SOAPElement;

 

public class SendSMSObjectHB implements Runnable {

    public String phones = null;//13345678901

    public String msg = null;// “object测试”;

 

    public int T_count = 0;

    public int tname = 0;

 

    public void run() {

        // System.out.println(“[TN:”+tname+”] “+T_count);

        long s = System.currentTimeMillis();

        String r = send2Imp(“abc”, “123456”, “1216”, 110, phones, msg);

        long e = System.currentTimeMillis();

        String time = (e – s) / 1000 == 0 ? (e – s) + “毫秒” : (e – s) / 1000

                + “秒” + (e – s) % 1000 + “毫秒”;

        System.out.println(“[TN:” + tname + “] P:” + phones + ” ST->” + time

                + “,R->” + r);

        // System.out.println(“ST->”+time+”,R->”+r );

    }

 

    public static String send2Imp(String sname, String spwd, String scorpid,

            int sprdid, String sdst, String smsg) {

        String ret = null;

        try {

           

            String nameSpace = “http://tempuri.org/”;

            String endPoint = “http://218.56.178.100/sms/service.asmx”;

            Service service = new Service();

            Call call = null;

            call = (Call) service.createCall();

            call.setTargetEndpointAddress(new URL(endPoint));

 

            call.setOperationName(new QName(nameSpace, “g_Submit”));

            call.addParameter(new QName(nameSpace, “sname”),

                    XMLType.XSD_STRING, ParameterMode.IN);

            call.addParameter(new QName(nameSpace, “spwd”), XMLType.XSD_STRING,

                    ParameterMode.IN);

            call.addParameter(new QName(nameSpace, “scorpid”),

                    XMLType.XSD_STRING, ParameterMode.IN);

            call.addParameter(new QName(nameSpace, “sprdid”),

                    XMLType.XSD_STRING, ParameterMode.IN);

            call.addParameter(new QName(nameSpace, “sdst”), XMLType.XSD_STRING,

                    ParameterMode.IN);

            call.addParameter(new QName(nameSpace, “smsg”), XMLType.XSD_STRING,

                    ParameterMode.IN);

 

            call.setReturnType(new javax.xml.namespace.QName(nameSpace,

                    “CSubmitState”));

            call.setReturnClass(CSubmitState.class);

            call.setUseSOAPAction(true);

            call.setSOAPActionURI(nameSpace + “g_Submit”);

             

            call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS,

                    Boolean.FALSE);

 

            Object css = call.invoke(new Object[] { sname, spwd, scorpid,

                    sprdid, sdst, smsg });

            System.out.println(“msgid:” + ((CSubmitState) css).getMsgID());

            System.out.println(“state:” + ((CSubmitState) css).getState());

            System.out.println(“reserve:” + ((CSubmitState) css).getReserve());

            System.out

                    .println(“msgstate:” + ((CSubmitState) css).getMsgState());

        } catch (Exception e) {

            e.printStackTrace();

        }

        return ret;

 

    }

 

    public static void main(String[] args) {

        send2Imp(“ABC”, “123456”, “1216”, 110, “15921256333”, “object测试”);

    }

}

 

==========================================================

CSubmitState 返回的对象的写法

======================================================

package com.madhouse;

public class CSubmitState  implements java.io.Serializable {

    private int state;

    private java.lang.String msgID;

    private java.lang.String msgState;

    private int reserve;

    public CSubmitState() {

    }

    public CSubmitState(

           int state,

           java.lang.String msgID,

           java.lang.String msgState,

           int reserve) {

           this.state = state;

           this.msgID = msgID;

           this.msgState = msgState;

           this.reserve = reserve;

    }

    /**

     * Gets the state value for this CSubmitState.

     *

     * @return state

     */

    public int getState() {

        return state;

    }

    /**

     * Sets the state value for this CSubmitState.

     *

     * @param state

     */

    public void setState(int state) {

        this.state = state;

    }

    /**

     * Gets the msgID value for this CSubmitState.

     *

     * @return msgID

     */

    public java.lang.String getMsgID() {

        return msgID;

    }

    /**

     * Sets the msgID value for this CSubmitState.

     *

     * @param msgID

     */

    public void setMsgID(java.lang.String msgID) {

        this.msgID = msgID;

    }

    /**

     * Gets the msgState value for this CSubmitState.

     *

     * @return msgState

     */

    public java.lang.String getMsgState() {

        return msgState;

    }

    /**

     * Sets the msgState value for this CSubmitState.

     *

     * @param msgState

     */

    public void setMsgState(java.lang.String msgState) {

        this.msgState = msgState;

    }

    /**

     * Gets the reserve value for this CSubmitState.

     *

     * @return reserve

     */

    public int getReserve() {

        return reserve;

    }

    /**

     * Sets the reserve value for this CSubmitState.

     *

     * @param reserve

     */

    public void setReserve(int reserve) {

        this.reserve = reserve;

    }

//    private java.lang.Object __equalsCalc = null;

//    public synchronized boolean equals(java.lang.Object obj) {

//        if (!(obj instanceof CSubmitState)) return false;

//        CSubmitState other = (CSubmitState) obj;

//        if (obj == null) return false;

//        if (this == obj) return true;

//        if (__equalsCalc != null) {

//            return (__equalsCalc == obj);

//        }

//        __equalsCalc = obj;

//        boolean _equals;

//        _equals = true &&

//            this.state == other.getState() &&

//            ((this.msgID==null && other.getMsgID()==null) ||

//             (this.msgID!=null &&

//              this.msgID.equals(other.getMsgID()))) &&

//            ((this.msgState==null && other.getMsgState()==null) ||

//             (this.msgState!=null &&

//              this.msgState.equals(other.getMsgState()))) &&

//            this.reserve == other.getReserve();

//        __equalsCalc = null;

//        return _equals;

//    }

//

//    private boolean __hashCodeCalc = false;

//    public synchronized int hashCode() {

//        if (__hashCodeCalc) {

//            return 0;

//        }

//        __hashCodeCalc = true;

//        int _hashCode = 1;

//        _hashCode += getState();

//        if (getMsgID() != null) {

//            _hashCode += getMsgID().hashCode();

//        }

//        if (getMsgState() != null) {

//            _hashCode += getMsgState().hashCode();

//        }

//        _hashCode += getReserve();

//        __hashCodeCalc = false;

//        return _hashCode;

//    }

    // Type metadata

    private static org.apache.axis.description.TypeDesc typeDesc =

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

    static {

        typeDesc.setXmlType(new javax.xml.namespace.QName(“http://tempuri.org/”, “CSubmitState”));

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

        elemField.setFieldName(“state”);

        elemField.setXmlName(new javax.xml.namespace.QName(“http://tempuri.org/”, “State”));

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

        elemField.setNillable(false);

        typeDesc.addFieldDesc(elemField);

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

        elemField.setFieldName(“msgID”);

        elemField.setXmlName(new javax.xml.namespace.QName(“http://tempuri.org/”, “MsgID”));

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

        elemField.setMinOccurs(0);

        elemField.setNillable(false);

        typeDesc.addFieldDesc(elemField);

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

        elemField.setFieldName(“msgState”);

        elemField.setXmlName(new javax.xml.namespace.QName(“http://tempuri.org/”, “MsgState”));

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

        elemField.setMinOccurs(0);

        elemField.setNillable(false);

        typeDesc.addFieldDesc(elemField);

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

        elemField.setFieldName(“reserve”);

        elemField.setXmlName(new javax.xml.namespace.QName(“http://tempuri.org/”, “Reserve”));

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

        elemField.setNillable(false);

        typeDesc.addFieldDesc(elemField);

    }

    /**

     * Return type metadata object

     */

    public static org.apache.axis.description.TypeDesc getTypeDesc() {

        return typeDesc;

    }

    /**

     * Get Custom Serializer

     */

    public static org.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 static org.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);

    }

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/100560.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 大数据平台解决方案

    大数据平台解决方案1、高负载和海量数据处理能力以云存储为基石,以云计算为处理核心,建立了海量的数据业务支撑的大数据平台。每天可以承受千万级PV的访问压力,支撑亿级用户及E8级各类数据存储如日志文件、图片、文档、影音等。基于此大数据支撑平台,不仅可以处理日以继夜增长的TB级数据增量,更能满足各类实时业务需求。2、业界领先的实时性在实时处理领域实现秒级突破,可以对各项业务数据惊醒实时查看与统计,方便客户快速

    2022年5月5日
    93
  • 动态链接库(DLL)初始化例程失败_load dll error解决

    动态链接库(DLL)初始化例程失败_load dll error解决UnabletoloadDLL’rasapi32.dll’:动态链接库(DLL)初始化例程失败。(ExceptionfromHRESULT:0x8007045A)解决方法:应用程序池-标识-选本地系统或者输入管理员身份的账户

    2022年10月9日
    1
  • Oracle 19c 新特性概要「建议收藏」

    Oracle 19c 新特性概要「建议收藏」本文概括出一些工作中可能会用到的Oracle19c新特性,所有新增功能的说明请参考新特性官方文档《database-new-features-guide》根据官方文档分为以下几个部分应用开发 可用性 大数据和数据仓库 整体数据库 性能 RAC和网格 安全 其他一、ApplicationDevelopment1.General1)EasyConne…

    2022年5月11日
    55
  • Pytest(10)assert断言[通俗易懂]

    Pytest(10)assert断言[通俗易懂]前言断言是写自动化测试基本最重要的一步,一个用例没有断言,就失去了自动化测试的意义了。什么是断言呢?简单来讲就是实际结果和期望结果去对比,符合预期那就测试pass,不符合预期那就测试failed

    2022年7月30日
    7
  • lombok插件失效原因_lombok插件下载

    lombok插件失效原因_lombok插件下载昨晚项目出了个小问题,lombok插件失效了。由于使用了lombok的@Data注解生成实体类的getter和setter,项目运行时所有的使用getter和setter方法的地方全都报错。看了网上的解决方案,一个一个试,发现没有一个能解决我的问题最后,我发现在pom.xml文件里面的<build></build>里面缺少了lombok的部分,把他加上即可<build><plugins><plugin

    2025年8月30日
    8
  • 计算机等级二级java试题(计算机考试选择题知识点)

    第一章数据结构与算法【考点1】算法的基本概念1、算法:是指一组有穷的指令集,是解题方案的准确而完整的描述。算法不等于程序,也不等于计算方法。2、算法的基本特征:1)确定性,算法中每一步骤都必须有明确定义,不允许有多义性;2)有穷性,算法必须能在有限的时间内做完,即能在执行有限个步骤后终止;3)可行性,算法原则上能够精确地执行;4)拥有足够的情报。3、算法的组成…

    2022年4月13日
    51

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号