Beispiel #1
0
  private boolean checkR2717AndR2726(final BindingOperation bop) {
    if (null == bop) {
      return true;
    }
    SoapBody inSoapBody = SOAPBindingUtil.getBindingInputSOAPBody(bop);
    SoapBody outSoapBody = SOAPBindingUtil.getBindingOutputSOAPBody(bop);
    if (inSoapBody != null && StringUtils.isEmpty(inSoapBody.getNamespaceURI())
        || outSoapBody != null && StringUtils.isEmpty(outSoapBody.getNamespaceURI())) {
      addErrorMessage(
          getErrorPrefix("WSI-BP-1.0 R2717")
              + "soapBody in the input/output of the binding operation '"
              + bop.getName()
              + "' MUST have namespace attribute");
      return false;
    }

    SoapHeader inSoapHeader = SOAPBindingUtil.getBindingInputSOAPHeader(bop);
    SoapHeader outSoapHeader = SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
    if (inSoapHeader != null && !StringUtils.isEmpty(inSoapHeader.getNamespaceURI())
        || outSoapHeader != null && !StringUtils.isEmpty(outSoapHeader.getNamespaceURI())) {
      addErrorMessage(
          getErrorPrefix("WSI-BP-1.0 R2726")
              + "Operation '"
              + bop.getName()
              + "' soapHeader MUST NOT have namespace attribute");
      return false;
    }

    List<SoapFault> soapFaults = SOAPBindingUtil.getBindingOperationSoapFaults(bop);
    for (SoapFault fault : soapFaults) {
      if (!StringUtils.isEmpty(fault.getNamespaceURI())) {
        addErrorMessage(
            getErrorPrefix("WSI-BP-1.0 R2726")
                + "Operation '"
                + bop.getName()
                + "' soapFault MUST NOT have namespace attribute");
        return false;
      }
    }
    return true;
  }
 public static String getActionURL(
     Definition wsdlDefinition,
     String serviceName,
     String portName,
     String bindingName,
     String opName) {
   Map<?, ?> services = wsdlDefinition.getServices();
   Set<?> serviceKeys = services.keySet();
   for (Iterator<?> it = serviceKeys.iterator(); it.hasNext(); ) {
     QName serviceKey = (QName) it.next();
     if (serviceName != null && serviceKey.getLocalPart().contentEquals(serviceName)) {
       Service service = (Service) services.get(serviceKey);
       Map<?, ?> ports = service.getPorts();
       Set<?> portKeys = ports.keySet();
       for (Iterator<?> it2 = portKeys.iterator(); it2.hasNext(); ) {
         String portKey = (String) it2.next();
         if (portName != null && portKey.contentEquals(portName)) {
           Port port = (Port) ports.get(portKey);
           Binding wsdlBinding = port.getBinding();
           List<?> operations = wsdlBinding.getBindingOperations();
           for (Iterator<?> it3 = operations.iterator(); it3.hasNext(); ) {
             BindingOperation operation = (BindingOperation) it3.next();
             if (opName != null && operation.getName().contentEquals(opName)) {
               List<?> attributesList = operation.getExtensibilityElements();
               for (Iterator<?> it4 = attributesList.iterator(); it4.hasNext(); ) {
                 Object test = it4.next();
                 if (test instanceof SOAPOperation) {
                   SOAPOperation soapOp = (SOAPOperation) test;
                   return soapOp.getSoapActionURI();
                 } else if (test instanceof SOAP12Operation) {
                   SOAP12Operation soapOp = (SOAP12Operation) test;
                   return soapOp.getSoapActionURI();
                 }
               }
             }
           }
         }
       }
     }
   }
   return null;
 }
Beispiel #3
0
  private void collectValidationPointsForBindings() throws Exception {
    Map<QName, XNode> vBindingNodes = new HashMap<QName, XNode>();
    for (Service service : services.values()) {
      vBindingNodes.putAll(getBindings(service));
    }

    for (Map.Entry<QName, XNode> entry : vBindingNodes.entrySet()) {
      QName bName = entry.getKey();
      Binding binding = this.definition.getBinding(bName);
      if (binding == null) {
        LOG.log(
            Level.SEVERE,
            bName.toString()
                + " is not correct, please check that the correct namespace is being used");
        throw new Exception(
            bName.toString()
                + " is not correct, please check that the correct namespace is being used");
      }
      XNode vBindingNode = getXNode(binding);
      vBindingNode.setFailurePoint(entry.getValue());
      vNodes.add(vBindingNode);

      if (binding.getPortType() == null) {
        continue;
      }
      portTypeRefNames.add(binding.getPortType().getQName());

      XNode vPortTypeNode = getXNode(binding.getPortType());
      vPortTypeNode.setFailurePoint(vBindingNode);
      vNodes.add(vPortTypeNode);
      Collection<BindingOperation> bops = CastUtils.cast(binding.getBindingOperations());
      for (BindingOperation bop : bops) {
        XNode vOpNode = getOperationXNode(vPortTypeNode, bop.getName());
        XNode vBopNode = getOperationXNode(vBindingNode, bop.getName());
        vOpNode.setFailurePoint(vBopNode);
        vNodes.add(vOpNode);
        if (bop.getBindingInput() != null) {
          String inName = bop.getBindingInput().getName();
          if (!StringUtils.isEmpty(inName)) {
            XNode vInputNode = getInputXNode(vOpNode, inName);
            vInputNode.setFailurePoint(getInputXNode(vBopNode, inName));
            vNodes.add(vInputNode);
          }
        }
        if (bop.getBindingOutput() != null) {
          String outName = bop.getBindingOutput().getName();
          if (!StringUtils.isEmpty(outName)) {
            XNode vOutputNode = getOutputXNode(vOpNode, outName);
            vOutputNode.setFailurePoint(getOutputXNode(vBopNode, outName));
            vNodes.add(vOutputNode);
          }
        }
        for (Iterator<?> iter1 = bop.getBindingFaults().keySet().iterator(); iter1.hasNext(); ) {
          String faultName = (String) iter1.next();
          XNode vFaultNode = getFaultXNode(vOpNode, faultName);
          vFaultNode.setFailurePoint(getFaultXNode(vBopNode, faultName));
          vNodes.add(vFaultNode);
        }
      }
    }
  }
Beispiel #4
0
  @SuppressWarnings("unchecked")
  public void transferOperations(Binding binding, boolean createRequests) {
    // prepare for transfer of operations/requests
    List<BindingOperation> newOperations =
        new ArrayList<BindingOperation>(binding.getBindingOperations());
    Map<String, WsdlOperation> oldOperations = new HashMap<String, WsdlOperation>();
    for (int c = 0; c < operations.size(); c++)
      oldOperations.put(operations.get(c).getBindingOperationName(), operations.get(c));

    // clear existing from both collections
    for (int c = 0; c < newOperations.size(); c++) {
      BindingOperation newOperation = newOperations.get(c);
      String bindingOperationName = newOperation.getName();
      if (oldOperations.containsKey(bindingOperationName)) {
        log.info("Synchronizing existing operation [" + bindingOperationName + "]");
        WsdlOperation wsdlOperation = oldOperations.get(bindingOperationName);
        WsdlUtils.getAnonymous(wsdlOperation);
        wsdlOperation.initFromBindingOperation(newOperation);
        fireOperationUpdated(wsdlOperation);

        oldOperations.remove(bindingOperationName);
        newOperations.remove(c);
        c--;
      }
    }

    // remove leftover operations
    Iterator<String> i = oldOperations.keySet().iterator();
    while (i.hasNext()) {
      String name = i.next();

      if (newOperations.size() > 0) {
        List<String> list = new ArrayList<String>();
        list.add("none - delete operation");
        for (int c = 0; c < newOperations.size(); c++) list.add(newOperations.get(c).getName());

        String retval =
            (String)
                UISupport.prompt(
                    "Binding operation ["
                        + name
                        + "] not found in new interface, select new\nbinding operation to map to",
                    "Map Operation",
                    list.toArray(),
                    "none/cancel - delete operation");

        int ix = retval == null ? -1 : list.indexOf(retval) - 1;

        // delete operation?
        if (ix < 0) {
          deleteOperation(name);
        }
        // change operation?
        else {
          BindingOperation newOperation = newOperations.get(ix);
          WsdlOperation wsdlOperation = oldOperations.get(name);
          wsdlOperation.initFromBindingOperation(newOperation);
          fireOperationUpdated(wsdlOperation);
          newOperations.remove(ix);
        }

        oldOperations.remove(name);
      } else {
        deleteOperation(name);
        oldOperations.remove(name);
      }

      i = oldOperations.keySet().iterator();
    }

    // add leftover new operations
    if (newOperations.size() > 0) {
      for (int c = 0; c < newOperations.size(); c++) {
        BindingOperation newOperation = newOperations.get(c);
        WsdlOperation wsdlOperation = addNewOperation(newOperation);

        if (createRequests) {
          WsdlRequest request = wsdlOperation.addNewRequest("Request 1");
          try {
            request.setRequestContent(wsdlOperation.createRequest(true));
          } catch (Exception e) {
            SoapUI.logError(e);
          }
        }
      }
    }
  }