soap 返回简单数据类型 wsdl webservice

soap 返回简单数据类型 wsdl webservice

import java.net.URL;

 

import javax.xml.namespace.QName;

import javax.xml.rpc.ParameterMode;

 

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.encoding.XMLType;

 

import org.apache.axis.message.SOAPHeaderElement;

import javax.xml.soap.SOAPElement;

 

public class SendSMSBJ2 implements Runnable {

    public String phones = null;//”15345667766″

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

 

    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 = send2BJ(username,  password,  mobile,  smscontent);

        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 send2BJ(String username,String password,String mobile,String smscontent) {

        String ret = null;

        String md5 = null;

        try {

           

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

            String endPoint = “http://www.ldsm.com/Service.asmx”;

 

            Service service = new Service();

            Call call = null;

             

            call = (Call) service.createCall();

            call.setTargetEndpointAddress(new URL(endPoint));

             

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

            call.addParameter(new QName(“http://DefaultNamespace”, “username”),

                    XMLType.XSD_STRING, ParameterMode.IN);

            call.addParameter(new QName(“http://DefaultNamespace”, “password”),

                    XMLType.XSD_STRING, ParameterMode.IN);

            call.addParameter(new QName(“http://DefaultNamespace”, “mobile”),

                    XMLType.XSD_STRING, ParameterMode.IN);

            call.addParameter(new QName(“http://DefaultNamespace”, “smscontent”),

                    XMLType.XSD_STRING, ParameterMode.IN);

 

            call.setReturnType(XMLType.XSD_INT);

 

            call.setUseSOAPAction(true);

            call.setSOAPActionURI(nameSpace + “SendSMS”);

 

            System.out.println(call.invoke(new Object[] { username,  password,  mobile,  smscontent}));

 

        } catch (Exception e) {

            e.printStackTrace();

        }

        return ret;

 

    }

 

  

    static String username=”saaa”;

    static String password=”123456″;

    static String smscontent=”abc测试”;

 

 

    static String mobile = “159211156331”;

     

    static String SendTime = “”;

 

    public static void main(String[] a) {

 

        send2BJ(  username,  password,  mobile,  smscontent);

 

 

    }

}

 

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

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

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


相关推荐

发表回复

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

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