[Java] webservice接口call调用方式 →→→→→进入此内容的聊天室

来自 , 2020-08-30, 写在 Java, 查看 98 次.
URL http://www.code666.cn/view/393c55ae
  1. //call调用方式
  2.         private String send(String method,String userName,String title,String content,String tel){
  3.                 String soapaction= "http://service.msgbuss.ceair.com/";
  4.             String endpoint  = "http://xxx.xx.xx.xx:8099/msgbuss/soap/sendMessage";
  5.             try {
  6.                 org.apache.axis.client.Service service = new org.apache.axis.client.Service();
  7.                 Call call = (Call)service.createCall();
  8.                 QName qn = new QName("urn:messageEndpoint", "MessageRequestVO");
  9.                 call.registerTypeMapping(MessageRequestVO.class,qn,
  10.                                  new BeanSerializerFactory(MessageRequestVO.class, qn),
  11.                              new BeanDeserializerFactory(MessageRequestVO.class, qn));
  12.                 call.setTargetEndpointAddress(endpoint);
  13.                 call.setUseSOAPAction(true);
  14.                 call.setSOAPActionURI(null);
  15.                 call.setOperationName(new QName(soapaction, "send"));
  16.                
  17.                 //判断是否是自定义手机号码
  18.                         JSONObject obj=new JSONObject();
  19.                         if(tel!= null ||!"".equals(tel) ){
  20.                                 obj.put("mobiles",tel);
  21.                         }
  22.                         obj.put("emsEnterpriseID","10090");
  23.                         obj.put("emsLoginName","admin");
  24.                         obj.put("emsPassword",MD5.toMD5("cabin123"));
  25.                        
  26.             //赋值
  27.             MessageRequestVO messageRequestVO = new MessageRequestVO();
  28.             messageRequestVO.setBizProduct(method);
  29.             messageRequestVO.setRequestId(UUID.randomUUID().toString());
  30.             messageRequestVO.setToUserId(userName);
  31.             messageRequestVO.setTitle(title);
  32.             messageRequestVO.setContent(content);
  33.             messageRequestVO.setExtention(obj.toString());
  34.            
  35.             String str = "<bizProduct>"+method+"</bizProduct>"
  36.                            + "<content>"+"测试1"+"</content>"
  37.                            + "<extention>"+obj.toString()+"</extention>"
  38.                            + "<requestId>11111</requestId>"
  39.                            + "<title>测试</title>"
  40.                            + "<toUserId>chenbiqian</toUserId>";
  41.            
  42.             call.addParameter("messageRequestVO", org.apache.axis.encoding.XMLType.XSD_STRING, ParameterMode.IN);
  43.             call.getParameterTypeByName("");
  44.             //call.addParameter("bizProduct", org.apache.axis.encoding.XMLType.XSD_STRING, ParameterMode.IN);
  45.             call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
  46.             call.invoke(new Object[] {str});
  47.             return null;
  48.                 } catch (Exception e) {
  49.                         e.printStackTrace();
  50.                 }
  51.             return  null;
  52.         }

回复 "webservice接口call调用方式"

这儿你可以回复上面这条便签

captcha