예제 #1
0
  public boolean updateDefinition(String url, boolean createRequests) throws Exception {
    WsdlContext.uncache(url);

    WsdlContext newContext = new WsdlContext(url, (WsdlInterface) null);
    if (!newContext.load()) {
      return false;
    }

    BindingTuple tuple = findBinding(newContext);
    if (tuple == null) return false;

    setBindingName(tuple.binding.getQName());

    // update name
    if (getSettings().getBoolean(WsdlSettings.NAME_WITH_BINDING))
      setName(tuple.binding.getQName().getLocalPart());

    // update context
    setWsdlContext(newContext);

    transferOperations(tuple.binding, createRequests);

    setDefinition(url, false);

    transferEndpoints(tuple.port);

    updateWsaPolicy(url, newContext);

    getProject().fireInterfaceUpdated(this);

    return true;
  }
예제 #2
0
  public BindingTuple prepareUpdateDefinition(String url) throws Exception {
    WsdlContext newContext = new WsdlContext(url, getSoapVersion());
    if (!newContext.load()) {
      return null;
    }

    BindingTuple tuple = findBinding(newContext);
    return tuple;
  }
예제 #3
0
  @Override
  public void release() {
    super.release();

    for (WsdlOperation operation : operations) operation.release();

    if (wsdlContext != null) wsdlContext.release();
  }
예제 #4
0
  public String getStyle() {
    if (wsdlContext == null || !wsdlContext.isLoaded()) return "<not loaded>";

    try {
      Binding binding = wsdlContext.getDefinition().getBinding(getBindingName());
      if (binding == null) return "<missing binding>";

      if (WsdlUtils.isRpc(binding)) {
        return STYLE_RPC;
      } else {
        return STYLE_DOCUMENT;
      }
    } catch (Exception e) {
      SoapUI.logError(e);
      return "<error>";
    }
  }
예제 #5
0
  public void setDefinition(String wsdlUrl, boolean updateCache) throws Exception {
    String old = definitionProperty.set(wsdlUrl, false);

    if (wsdlContext != null) {
      wsdlContext.setDefinition(definitionProperty.expandUrl(), updateCache);
    }

    notifyPropertyChanged(DEFINITION_PROPERTY, old, wsdlUrl);
    notifyPropertyChanged(UPDATING_PROPERTY, true, false);
  }
예제 #6
0
  public boolean isCached() {
    if (wsdlContext != null && wsdlContext.isCached()) {
      return true;
    }

    DefinitionCacheConfig cacheConfig = getConfig().getDefinitionCache();
    if (cacheConfig == null
        || cacheConfig.getRootPart() == null
        || cacheConfig.sizeOfPartArray() == 0) return false;

    return true;
  }
예제 #7
0
  public void updateDefinition(BindingTuple tuple) throws Exception {
    setBindingName(tuple.binding.getQName());

    if (getConfig().isSetDefinitionCache()) getConfig().unsetDefinitionCache();

    // update name
    if (getSettings().getBoolean(WsdlSettings.NAME_WITH_BINDING))
      setName(tuple.binding.getQName().getLocalPart());

    // update context
    wsdlContext = tuple.context;
    wsdlContext.setInterface(this);
    if (soapMessageBuilder != null) soapMessageBuilder.setWsdlContext(wsdlContext);
  }
예제 #8
0
  @SuppressWarnings("unchecked")
  private BindingTuple findBinding(WsdlContext newContext) throws Exception {
    BindingTuple tuple = new BindingTuple();
    tuple.context = newContext;

    // start by finding the old binding in the new definition
    Definition definition = newContext.getDefinition();
    Map serviceMap = definition.getAllServices();
    Iterator<String> i = serviceMap.keySet().iterator();
    while (i.hasNext()) {
      tuple.service = (Service) serviceMap.get(i.next());
      Map portMap = tuple.service.getPorts();

      Iterator i2 = portMap.keySet().iterator();
      while (i2.hasNext()) {
        tuple.port = (Port) portMap.get(i2.next());
        if (tuple.port.getBinding().getQName().equals(getBindingName())) {
          tuple.binding = tuple.port.getBinding();
        }
      }

      if (tuple.binding != null) break;
      tuple.service = null;
    }

    if (tuple.service == null && tuple.binding == null) {
      tuple.binding = definition.getBinding(getBindingName());
    }

    // missing matching binding, prompt for new one to use instead (will
    // happen if binding has been renamed)
    if (tuple.binding == null) {
      Map bindings = definition.getAllBindings();

      Object retval =
          UISupport.prompt(
              "Missing matching binding ["
                  + getBindingName()
                  + "] in definition, select new\nbinding to map to",
              "Map Binding",
              bindings.keySet().toArray());

      if (retval == null) return null;

      tuple.binding = (Binding) bindings.get(retval);
    }

    return tuple;
  }
예제 #9
0
  private void updateWsaPolicy(String url, WsdlContext newContext) throws Exception {

    Definition definition = newContext.getDefinition();
    policyFlag = false;
    processPolicy(PolicyUtils.getAttachedPolicy(getBinding(), definition));
    Map<?, ?> serviceMap = definition.getAllServices();
    if (serviceMap.isEmpty()) log.info("Missing services in [" + url + "], check for bindings");
    else {
      Iterator<?> i = serviceMap.values().iterator();
      while (i.hasNext()) {
        Service service = (Service) i.next();
        Map<?, ?> portMap = service.getPorts();
        Iterator<?> i2 = portMap.values().iterator();
        while (i2.hasNext()) {
          Port port = (Port) i2.next();
          processPolicy(PolicyUtils.getAttachedPolicy(port, definition));
        }
      }
    }
  }