webservice接口调用方式——call调用方式


    private String send(String method,String userName,String title,String content,String tel){
        String soapaction= "http://service.msgbuss.ceair.com/";
        String endpoint  = "http://xxx.xx.xx.xx:8099/msgbuss/soap/sendMessage";
        try {
            org.apache.axis.client.Service service = new org.apache.axis.client.Service();
            Call call = (Call)service.createCall();
            QName qn = new QName("urn:messageEndpoint", "MessageRequestVO");
            call.registerTypeMapping(MessageRequestVO.class,qn,
                     new BeanSerializerFactory(MessageRequestVO.class, qn),
                     new BeanDeserializerFactory(MessageRequestVO.class, qn));
            call.setTargetEndpointAddress(endpoint);
            call.setUseSOAPAction(true);
            call.setSOAPActionURI(null);
            call.setOperationName(new QName(soapaction, "send"));
            
            //判断是否是自定义手机号码
            JSONObject obj=new JSONObject();
            if(tel!= null ||!"".equals(tel) ){
                obj.put("mobiles",tel);
            }
            obj.put("emsEnterpriseID","10090");
            obj.put("emsLoginName","admin");
            obj.put("emsPassword",MD5.toMD5("cabin123"));
            
            //赋值
            MessageRequestVO messageRequestVO = new MessageRequestVO();
            messageRequestVO.setBizProduct(method);
            messageRequestVO.setRequestId(UUID.randomUUID().toString());
            messageRequestVO.setToUserId(userName);
            messageRequestVO.setTitle(title);
            messageRequestVO.setContent(content);
            messageRequestVO.setExtention(obj.toString());
            
            String str = "<bizProduct>"+method+"</bizProduct>"
                       + "<content>"+"测试1"+"</content>"
                       + "<extention>"+obj.toString()+"</extention>"
                       + "<requestId>11111</requestId>"
                       + "<title>测试</title>"
                       + "<toUserId>chenbiqian</toUserId>";
            
            call.addParameter("messageRequestVO", org.apache.axis.encoding.XMLType.XSD_STRING, ParameterMode.IN);
            call.getParameterTypeByName("");
            //call.addParameter("bizProduct", org.apache.axis.encoding.XMLType.XSD_STRING, ParameterMode.IN);
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
            call.invoke(new Object[] {str});
            return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return  null;
    }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM