コード例 #1
0
  public void init(String urlStr, String cookieString) throws Exception {
    if (_service != null) {
      disconnect();
    }
    _locator = new VimServiceLocator();
    _locator.setMaintainSession(true);
    _service = _locator.getVimPort(new URL(urlStr));
    _sic = _service.retrieveServiceContent(_svcRef);

    org.apache.axis.client.Stub st = (org.apache.axis.client.Stub) _service;
    org.apache.axis.client.Call callObj = st._getCall();
    org.apache.axis.MessageContext msgContext = callObj.getMessageContext();
    msgContext.setProperty(
        org.apache.axis.transport.http.HTTPConstants.HEADER_COOKIE, cookieString);

    _svcState = ConnectionState_Connected;
  }
コード例 #2
0
    public void run() {
      LocalTransport transport = new LocalTransport(server);
      transport.setRemoteService(SERVICE_NAME);
      Call call = new Call(new Service());
      call.setTransport(transport);

      for (int i = 0; i < reps; i++) {
        try {
          String ret = (String) call.invoke("hello", null);
          if (ret == null) {
            MessageContext msgContext = call.getMessageContext();
            String respStr = msgContext.getResponseMessage().getSOAPPartAsString();

            String reqStr = msgContext.getRequestMessage().getSOAPPartAsString();
            String nullStr =
                "Got null response! Request message:\r\n"
                    + reqStr
                    + "\r\n\r\n"
                    + "Response message:\r\n"
                    + respStr;
            log.fatal(nullStr);
            setError(new Exception(nullStr));
          } else if (!ret.equals(TestService.MESSAGE)) {
            setError(
                new Exception(
                    "Messages didn't match (got '"
                        + ret
                        + "' wanted '"
                        + TestService.MESSAGE
                        + "'!"));
            return;
          }
        } catch (AxisFault axisFault) {
          setError(axisFault);
          return;
        }
      }
    }
コード例 #3
0
ファイル: SMSHelper.java プロジェクト: ukekeu/001
  public static String SendSMS(String[] mobileNum, int msgId, String msg) {
    Service service = new Service();

    String ret = "-1";
    String uc = Const.HWWebServiceUser;
    try {
      Call call = (Call) service.createCall();
      call.setTargetEndpointAddress(Const.HWWebServiceRegisterURL);
      call.setOperationName("getRandom");
      call.setReturnType(XMLType.XSD_STRING);
      call.getMessageContext().setUsername("test");
      call.getMessageContext().setPassword("test");

      ret = (String) call.invoke(new Object[0]);
      log.info("random=           " + ret);
      String rand = ret;
      String pw = Md5.MD5(rand + Const.HWWebServiceUserPasswd + Const.HWWebServiceUserPasswd);

      call = (Call) service.createCall();
      call.setTargetEndpointAddress(new URL(Const.HWWebServiceRegisterURL));
      call.setOperationName("setCallBackAddr");
      call.addParameter("uc", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("pw", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("rand", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("url", XMLType.XSD_STRING, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_STRING);
      call.getMessageContext().setUsername("test");
      call.getMessageContext().setPassword("test");
      String myUrl = Const.CallBackURL;

      ret = (String) call.invoke(new Object[] {uc, pw, rand, myUrl});
      log.info("connId:" + ret);
      String connId = ret;

      call = (Call) service.createCall();
      call.setTargetEndpointAddress(Const.HWWebServiceRegisterURL);
      call.setOperationName("getRandom");
      call.setReturnType(XMLType.XSD_STRING);
      call.getMessageContext().setUsername("test");
      call.getMessageContext().setPassword("test");

      ret = (String) call.invoke(new Object[0]);
      log.info("random:" + ret);
      rand = ret;
      pw = Md5.MD5(rand + Const.HWWebServiceUserPasswd + Const.HWWebServiceUserPasswd);

      call = (Call) service.createCall();
      call.setTargetEndpointAddress(new URL(Const.HWWebServiceSMSURL));
      call.setOperationName("sendSMS");

      call.addParameter("uc", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("pw", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("rand", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("callee", XMLType.XSD_ANYTYPE, ParameterMode.IN);
      call.addParameter("isreturn", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("cont", XMLType.XSD_STRING, ParameterMode.IN);
      call.addParameter("msgid", XMLType.XSD_INTEGER, ParameterMode.IN);
      call.addParameter("connID", XMLType.XSD_STRING, ParameterMode.IN);
      call.setReturnType(XMLType.XSD_STRING);

      call.getMessageContext().setUsername("test");
      call.getMessageContext().setPassword("test");

      msg = new BASE64Encoder().encode(msg.getBytes("gb2312"));
      log.info("msg:" + msg);

      log.info("MSGID:" + msgId);

      ret =
          (String)
              call.invoke(
                  new Object[] {uc, pw, rand, mobileNum, "1", msg, Integer.valueOf(msgId), connId});

      log.info("status:" + ret);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return ret;
  }