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