Package com.eviware.soapui.impl.wsdl

Examples of com.eviware.soapui.impl.wsdl.WsdlInterface


      return;
    }

    if( UISupport.confirm( "Overwrite current response with a fault message?", "Create Fault" ) )
    {
      WsdlInterface iface = operation.getInterface();
      MessagePart[] faultParts = operation.getFaultParts();

      if( faultParts != null && faultParts.length > 0 )
      {
        List<String> names = new ArrayList<String>();
        for( int c = 0; c < faultParts.length; c++ )
          names.add( faultParts[c].getName() );

        String faultName = UISupport.prompt( "Select fault detail to generate", "Create Fault", names );
        if( faultName != null )
        {
          FaultPart faultPart = ( FaultPart )faultParts[names.indexOf( faultName )];
          mockResponse.setResponseContent( iface.getMessageBuilder().buildFault( faultPart ) );
        }
      }
      else
      {
        mockResponse.setResponseContent( iface.getMessageBuilder().buildEmptyFault() );
      }
    }
  }
View Full Code Here


  public WsdlInterface importBinding( WsdlProject project, WsdlContext wsdlContext, Binding binding ) throws Exception
  {
    String name = project.getSettings().getBoolean( WsdlSettings.NAME_WITH_BINDING ) ? binding.getQName()
        .getLocalPart() : binding.getPortType().getQName().getLocalPart();

    WsdlInterface iface = ( WsdlInterface )project.addNewInterface( name, WsdlInterfaceFactory.WSDL_TYPE );
    iface.setBindingName( binding.getQName() );
    iface.setSoapVersion( SoapVersion.Soap12 );

    String[] endpoints = WsdlUtils.getEndpointsForBinding( wsdlContext.getDefinition(), binding );
    for( int i = 0; i < endpoints.length; i++ )
    {
      log.info( "importing endpoint " + endpoints[i] );
      iface.addEndpoint( endpoints[i] );
    }

    List<BindingOperation> list = binding.getBindingOperations();
    Collections.sort( list, new BindingOperationComparator() );

    for( Iterator<BindingOperation> iter = list.iterator(); iter.hasNext(); )
    {
      BindingOperation operation = ( BindingOperation )iter.next();

      // sanity check
      if( operation.getOperation() == null || operation.getOperation().isUndefined() )
      {
        log.error( "BindingOperation [" + operation.getName() + "] is missing or referring to an invalid operation" );
      }
      else
      {
        log.info( "importing operation " + operation.getName() );
        iface.addNewOperation( operation );
      }
    }

    initWsAddressing( binding, iface, wsdlContext.getDefinition() );
View Full Code Here

      printWsdl( response );
      return;
    }

    String ifaceName = request.getParameter( "interface" );
    WsdlInterface iface = ( WsdlInterface )mockService.getProject().getInterfaceByName( ifaceName );
    if( iface == null )
    {
      printInterfaceList( response );
      return;
    }

    StringToStringMap parts = wsdlCache.get( iface.getName() );
    String part = request.getParameter( "part" );
    String content = StringUtils.isNullOrEmpty( part ) ? null : parts.get( part );

    if( content == null )
    {
View Full Code Here

    Definition definition = wsdlContext.getDefinition();
    List<WsdlInterface> result = new ArrayList<WsdlInterface>();
    if( bindingName != null )
    {
      WsdlInterface iface = importBinding( project, wsdlContext,
          ( Binding )definition.getAllBindings().get( bindingName ) );
      return iface == null ? new WsdlInterface[0] : new WsdlInterface[] { iface };
    }

    Map<Binding, WsdlInterface> importedBindings = new HashMap<Binding, WsdlInterface>();

    Map<?, ?> serviceMap = definition.getAllServices();
    if( serviceMap.isEmpty() )
      log.info( "Missing services in [" + wsdlUrl + "], 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();

          Binding binding = port.getBinding();
          if( importedBindings.containsKey( binding ) )
          {
            // add endpoint since it could differ from already imported
            // one..
            String endpoint = WsdlUtils.getSoapEndpoint( port );
            if( endpoint != null )
              importedBindings.get( binding ).addEndpoint( endpoint );

            continue;
          }

          String ifaceName = getInterfaceNameForBinding( binding );
          WsdlInterface ifc = ( WsdlInterface )project.getInterfaceByName( ifaceName );
          if( ifc != null )
          {
            Boolean res = UISupport.confirmOrCancel( "Interface [" + ifc.getName()
                + "] already exists in project, update instead?", "Import WSDL" );
            if( res == null )
              return new WsdlInterface[0];

            if( res.booleanValue() )
            {
              if( ifc.updateDefinition( wsdlUrl, false ) )
              {
                importedBindings.put( binding, ifc );
                result.add( ifc );
              }
            }

            continue;
          }

          WsdlInterface iface = importBinding( project, wsdlContext, binding );
          if( iface != null )
          {
            String endpoint = WsdlUtils.getSoapEndpoint( port );
            if( endpoint != null )
              iface.addEndpoint( endpoint );
            // NOTE: question is what has priority wsaw:usingAddressing or
            // wsam:Addressing policy
            // in case addressing is defined both ways in the wsdl and
            // there is conflict
            // currently the first one that's set is final
            // first is checked wsdl binding and policy attachment
            // and then for port in the same order

            if( iface.getWsaVersion().equals( WsaVersionTypeConfig.NONE.toString() ) )
              iface.setWsaVersion( WsdlUtils.getUsingAddressing( port ) );
            if( iface.getWsaVersion().equals( WsaVersionTypeConfig.NONE.toString() ) )
            {
              iface.processPolicy( PolicyUtils.getAttachedPolicy( port, wsdlContext.getDefinition() ) );
            }

            result.add( iface );
            importedBindings.put( binding, iface );
          }
        }
      }
    }

    Map<?, ?> bindingMap = definition.getAllBindings();
    if( !bindingMap.isEmpty() )
    {
      Iterator<?> i = bindingMap.values().iterator();
      while( i.hasNext() )
      {
        Binding binding = ( Binding )i.next();
        if( importedBindings.containsKey( binding ) )
        {
          continue;
        }

        PortType portType = binding.getPortType();
        if( portType == null )
        {
          log.warn( "Missing portType for binding [" + binding.getQName().toString() + "]" );
        }
        else
        {
          String ifaceName = getInterfaceNameForBinding( binding );
          WsdlInterface ifc = ( WsdlInterface )project.getInterfaceByName( ifaceName );
          if( ifc != null && result.indexOf( ifc ) == -1 )
          {
            Boolean res = UISupport.confirmOrCancel( "Interface [" + ifc.getName()
                + "] already exists in project, update instead?", "Import WSDL" );
            if( res == null )
              return new WsdlInterface[0];

            if( res.booleanValue() )
            {
              if( ifc.updateDefinition( wsdlUrl, false ) )
              {
                importedBindings.put( binding, ifc );
                result.add( ifc );
              }
            }

            continue;
          }

          WsdlInterface iface = importBinding( project, wsdlContext, binding );
          if( iface != null )
          {
            result.add( iface );
            importedBindings.put( binding, ifc );
          }
View Full Code Here

    {
      BindingImporter importer = bindingImporters.get( c );
      if( importer.canImport( binding ) )
      {
        log.info( "Importing binding " + binding.getQName() );
        WsdlInterface iface = importer.importBinding( project, wsdlContext, binding );

        String url = wsdlContext.getUrl();
        iface.setDefinition( url );

        return iface;
      }
    }
    log.info( "Missing importer for " + binding.getQName() );
View Full Code Here

    return getMockResponse().getMockOperation().getOperation();
  }

  public void setInterface( String string )
  {
    WsdlInterface iface = ( WsdlInterface )getTestCase().getTestSuite().getProject().getInterfaceByName( string );
    if( iface != null )
    {
      mockResponseStepConfig.setInterface( iface.getName() );
      WsdlOperation operation = iface.getOperationAt( 0 );
      mockResponseStepConfig.setOperation( operation.getName() );
      mockOperation.setOperation( operation );
    }
  }
View Full Code Here

    WsdlOperation operation = null;
    for( int c = 0; c < project.getInterfaceCount(); c++ )
    {
      if( project.getInterfaceAt( c ).getName().equals( requestStepConfig.getInterface() ) )
      {
        WsdlInterface iface = ( WsdlInterface )project.getInterfaceAt( c );
        for( int i = 0; i < iface.getOperationCount(); i++ )
        {
          if( iface.getOperationAt( i ).getName().equals( requestStepConfig.getOperation() ) )
          {
            operation = iface.getOperationAt( i );
            break;
          }
        }

        if( operation != null )
View Full Code Here

      @Override
      public SchemaType getSchemaType()
      {
        try
        {
          WsdlInterface iface = getOperation().getInterface();
          if( WsdlUtils.isRpc( iface.getBinding() ) )
            return WsdlUtils.generateRpcBodyType( getOperation() );
          else
            return iface.getDefinitionContext().getSchemaTypeSystem()
                .findElement( getOperation().getRequestBodyElementQName() ).getType();
        }
        catch( Exception e )
        {
          SoapUI.logError( e );
View Full Code Here

    }

    private void testLoader(String wsdlUrl) throws Exception {
        WsdlProject project = new WsdlProject();
        project.getSettings().setBoolean(WsdlSettings.CACHE_WSDLS, true);
        WsdlInterface wsdlInterface = WsdlImporter.importWsdl(project, wsdlUrl)[0];

        assertTrue(wsdlInterface.isCached());

        WsdlDefinitionExporter exporter = new WsdlDefinitionExporter(wsdlInterface);

        String root = exporter.export(OUTPUT_FOLDER_BASE_PATH + "test" + File.separatorChar + "output");

        WsdlProject project2 = new WsdlProject();
        WsdlInterface wsdl2 = WsdlImporter.importWsdl(project2, new File(root).toURI().toURL().toString())[0];

        assertEquals(wsdlInterface.getBindingName(), wsdl2.getBindingName());
        assertEquals(wsdlInterface.getOperationCount(), wsdl2.getOperationCount());
        assertEquals(wsdlInterface.getWsdlContext().getInterfaceDefinition().getDefinedNamespaces(), wsdl2
                .getWsdlContext().getInterfaceDefinition().getDefinedNamespaces());
    }
View Full Code Here

                if (item == null || getProject().getInterfaceByName(item) == null) {
                    operationFilterModel.addElement(ALL_FILTER_OPTION);
                    interfaceFilter.setPattern(".*", 0);
                } else if (getProject().getInterfaceByName(item) != null) {
                    WsdlInterface iface = (WsdlInterface) getProject().getInterfaceByName(item);
                    String[] operationNames = ModelSupport.getNames(new String[]{ALL_FILTER_OPTION},
                            iface.getOperationList());
                    for (String s : operationNames) {
                        operationFilterModel.addElement(s);
                    }

                    interfaceFilter.setPattern(iface.getName(), 0);
                }
            }
        });

        toolbar.addFixed(new JLabel("Operation"));
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.wsdl.WsdlInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.