コード例 #1
0
  /**
   * 受け取ったアクションを送信し、結果を受け取ります。
   *
   * @param action SOAP アクション
   * @return org.apache.axiom.om.OMElement レスポンス
   * @throws AxisFault サーバーと接続エラー
   */
  public OMElement sendReceive(Action action) throws AxisFault {
    this.serviceClient.removeHeaders();

    // Set URL
    URI uri;

    if (this.garoonURI.toString().indexOf(".cgi") > -1
        || this.garoonURI.toString().indexOf(".exe") > -1) {
      try {
        if (this.garoonURI.getQuery() == null) {
          uri = new URI(this.garoonURI.toString() + action.getAPIType().getPath());
        } else { // GR Liteの場合
          uri =
              new URI(
                  this.garoonURI.getScheme()
                      + "://"
                      + this.garoonURI.getHost()
                      + this.garoonURI.getPath()
                      + action.getAPIType().getPath()
                      + "?"
                      + this.garoonURI.getQuery());
        }
      } catch (URISyntaxException e) {
        throw new AxisFault(
            "Invalid URL:" + this.garoonURI.toString() + action.getAPIType().getPath());
      }
    } else {
      try {
        //            uri = new URI(this.garoonURI.toString() + action.getAPIType().getPath());
        uri = new URI(this.garoonURI.toString() + action.getAPIType().getPath() + ".csp");
      } catch (URISyntaxException e) {
        //            throw new AxisFault("Invalid URL:" + this.garoonURI.toString() +
        // action.getAPIType().getPath());
        throw new AxisFault(
            "Invalid URL:" + this.garoonURI.toString() + action.getAPIType().getPath() + ".csp");
      }
    }

    // Add Header
    OMElement header =
        HeaderFactory.create(
            action.getActionName(),
            this.username,
            this.password,
            this.createdTime,
            this.expiredTime);
    this.serviceClient.addHeader(header);

    // Set Options
    Options options = OptionsFactory.create(uri, this.scheme, action.getActionName());
    options.setProperty(HTTPConstants.COOKIE_POLICY, CookiePolicy.BROWSER_COMPATIBILITY);
    this.serviceClient.setOptions(options);

    OMElement request = getRequest(action);
    OMElement result = this.serviceClient.sendReceive(request);

    return result;
  }
コード例 #2
0
 /**
  * Add an action for the specified behavior. Before calling this method, the caller should verify
  * that the action is valid for the given behavior, meaning that the action string is a valid
  * method call in the given category (for the atomic action) and the child-actions are valid (for
  * the composite and behavior action).
  *
  * <p>If the action already exists, the new one will replace the old one without any promotes.
  *
  * <p>The action name and the action string and the child actions , if any, should be populated
  * well, before calling this method.
  *
  * @param id ID of the behavior where the action is associated to
  * @param action The action to be associated to
  */
 public void addAction(int id, Action action) {
   Map actions = (Map) this.behaviorActions.get(new Integer(id));
   if (actions == null) {
     actions = new HashMap();
     this.behaviorActions.put(new Integer(id), actions);
   }
   actions.put(action.getActionName(), action);
 }
コード例 #3
0
 private OMElement getRequest(Action action) {
   OMElement request = this.omFactory.createOMElement(action.getActionName(), this.omNs);
   OMElement parameters = action.getParameters();
   request.addChild(parameters);
   return request;
 }