关于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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 基于深度学习的车辆检测系统(MATLAB代码,含GUI界面)

    基于深度学习的车辆检测系统(MATLAB代码,含GUI界面)摘要:当前深度学习在目标检测领域的影响日益显著,本文主要基于深度学习的目标检测算法实现车辆检测,为大家介绍如何利用MATLAB设计一个车辆检测系统的软件,通过自行搭建YOLO网络并利用自定义的数据集进行训练、验证模型,最终实现系统可选取图片或视频进行检测、标注,以及结果的实时显示和保存。其中,GUI界面利用最新的MATLABAPP设计工具开发设计完成,算法部分选择时下实用的YOLOv2/v3网络,通过BDD100K数据集进行训练、测试检测器效果。本文提供项目所有涉及到的程序代码、数据集等文件,完整资源。

    2022年10月15日
  • Hmily:高性能异步分布式事务TCC框架「建议收藏」

    Hmily:高性能异步分布式事务TCC框架「建议收藏」作者:xiaoyu  来源:分布式事务技术研究Hmily框架特性[https://github.com/yu199195/hmily]无缝集成Spring,Spring…

    2022年5月21日
  • UCF约束介绍_flcl alternative

    UCF约束介绍_flcl alternative约束(一)约束的分类:利用FPGA进行系统设计常用的约束主要分为3类。(1)时序约束:主要用于规范设计的时序行为,表达设计者期望满足的时序条件,知道综合和布局布线阶段的优化算法等。(2)布局布

    2022年8月2日
  • asp.net repeater_asp.net core

    asp.net repeater_asp.net coreasp.net在Repeater嵌套的Repeater中使用复选框来自森大科技官方博客http://www.cnsendblog.com/index.php/?p=109.aspx文件中:<%–顶层Repeater–%><asp:RepeaterID=“rptChannel”runat=“server”><%#Eval(“ChannelName”…

    2022年10月13日
  • Quartz定时任务的组件API[通俗易懂]

    title:Quartz技术(二)-Quartz组件APIcategories:后端tags:定时任务本讲主要说明Quartz中重要的几个组件的API。Scheduler(调度器)Scheduler的生命期,从SchedulerFactory创建它时开始,到Scheduler调用shutdown()方法时结束;Scheduler被创建后,可以增加、删除和列举Job和Tri…

    2022年4月9日
  • 简单的使用protobuf和protostuff「建议收藏」

    简单的使用protobuf和protostuff「建议收藏」在我们的开发过程中,序列化是经常需要处理的问题,比如在做分布式访问数据时,或者是在做redis缓存存储数据时,如果我们涉及的知识面不够广的话,可能会简单的使用JDK的序列化,也即在需要序列化的类上implements Serializable接口去实现序列化,我想说的是这种方式在小系统中尚且可以用一用,如果是并发很大的系统会受到严重影响,这是由于JDK自带的序列化效率很低,不论是时间上还是空间上。

    2022年5月27日

发表回复

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

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