javax.wsdl.Definition Java Examples

The following examples show how to use javax.wsdl.Definition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JAXWSBindingDeserializer.java    From cxf with Apache License 2.0 6 votes vote down vote up
public ExtensibilityElement unmarshall(@SuppressWarnings("rawtypes") Class parentType,
                                       QName elementType,
                                       Element el,
                                       Definition def,
                                       ExtensionRegistry extReg) throws WSDLException {
    JAXWSBinding jaxwsBinding = (JAXWSBinding)extReg.createExtension(parentType, elementType);

    jaxwsBinding.setElementType(elementType);
    jaxwsBinding.setElement(el);
    jaxwsBinding.setDocumentBaseURI(def.getDocumentBaseURI());

    JAXWSBindingParser parser = new JAXWSBindingParser(extReg);
    parser.parseElement(jaxwsBinding, el);

    return jaxwsBinding;
}
 
Example #2
Source File: WSDLToCorbaBinding.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addCorbaTypes(Definition definition) throws Exception {
    for (XmlSchema xmlSchemaTypes : xmlSchemaList.getXmlSchemas()) {

        for (XmlSchemaExternal ext : xmlSchemaTypes.getExternals()) {
            addCorbaTypes(ext.getSchema());
            // REVISIT: This was preventing certain types from being added to the corba
            // typemap even when they are referenced from other parts of the wsdl.
            //
            // Should this add the corba types if it IS an instance of the XmlSchemaImport
            // (and not an XmlSchemaInclude or XmlSchemaRedefine)?
            //if (!(extSchema instanceof XmlSchemaImport)) {
            //    addCorbaTypes(extSchema.getSchema());
            //}
        }
        if (!W3CConstants.NU_SCHEMA_XSD.equals(xmlSchemaTypes.getTargetNamespace())) {
            addCorbaTypes(xmlSchemaTypes);
        }
    }
}
 
Example #3
Source File: WSDLToCorbaBindingTypeTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testCorbaExceptionComplextype() throws Exception {

    try {
        String fileName = getClass().getResource("/wsdl/databaseService.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("Database");

        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(2, typemap.getElementsByTagName("corba:struct").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:exception").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:anonsequence").getLength());
    } finally {
        new File("databaseService-corba.wsdl").deleteOnExit();
    }
}
 
Example #4
Source File: WSDLImporter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * Imports services and operations from the WSDL definition
 */
protected void importServicesAndOperations(Definition definition) {
  for (Object serviceObject : definition.getServices().values()) {
    Service service = (Service) serviceObject;
    WSService wsService = this.importService(service);
    this.wsServices.put(this.namespace + wsService.getName(), wsService);

    Port port = (Port) service.getPorts().values().iterator().next();
    for (Object bindOperationObject : port.getBinding().getBindingOperations()) {
      BindingOperation bindOperation = (BindingOperation) bindOperationObject;
      WSOperation operation = this.processOperation(bindOperation.getOperation(), wsService);
      wsService.addOperation(operation);

      this.wsOperations.put(this.namespace + operation.getName(), operation);
    }
  }
}
 
Example #5
Source File: WSDLImporter.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Imports services and operations from the WSDL definition
 */
protected void importServicesAndOperations(Definition definition) {
    for (Object serviceObject : definition.getServices().values()) {
        Service service = (Service) serviceObject;
        WSService wsService = this.importService(service);
        this.wsServices.put(this.namespace + wsService.getName(), wsService);

        Port port = (Port) service.getPorts().values().iterator().next();
        for (Object bindOperationObject : port.getBinding().getBindingOperations()) {
            BindingOperation bindOperation = (BindingOperation) bindOperationObject;
            WSOperation operation = this.processOperation(bindOperation.getOperation(), wsService);
            wsService.addOperation(operation);

            this.wsOperations.put(this.namespace + operation.getName(), operation);
        }
    }
}
 
Example #6
Source File: ScopedNameVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static boolean accept(Scope scope,
                             Definition defn,
                             XmlSchema schemaRef,
                             AST node,
                             WSDLASTVisitor wsdlVisitor,
                             boolean asName) {
    boolean result = false;
    if (PrimitiveTypesVisitor.accept(node)) {
        result = true;
    } else if (isforwardDeclared(scope, node, wsdlVisitor, asName)) {
        result = true;
    } else if (ObjectReferenceVisitor.accept(scope,
                                             schemaRef,
                                             defn,
                                             node,
                                             wsdlVisitor)) {
        result = true;
    } else if (findSchemaType(scope, defn, schemaRef, node, wsdlVisitor, null, asName)) {
        result = true;
    }
    return result;
}
 
Example #7
Source File: SoapProtocol.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void parseWSDLTypes( XSOMParser schemaParser )
	throws IOException {
	Definition definition = getWSDLDefinition();
	if( definition != null ) {
		Types types = definition.getTypes();
		if( types != null ) {
			List< ExtensibilityElement > list = types.getExtensibilityElements();
			for( ExtensibilityElement element : list ) {
				if( element instanceof SchemaImpl ) {
					Element schemaElement = ((SchemaImpl) element).getElement();
					Map< String, String > namespaces = definition.getNamespaces();
					for( Entry< String, String > entry : namespaces.entrySet() ) {
						if( entry.getKey().equals( "xmlns" ) || entry.getKey().trim().isEmpty() ) {
							continue;
						}
						if( schemaElement.getAttribute( "xmlns:" + entry.getKey() ).isEmpty() ) {
							schemaElement.setAttribute( "xmlns:" + entry.getKey(), entry.getValue() );
						}
					}
					parseSchemaElement( definition, schemaElement, schemaParser );
				}
			}
		}
	}
}
 
Example #8
Source File: ManagementBusInvocationPluginSoapHttp.java    From container with Apache License 2.0 6 votes vote down vote up
private BindingOperation findOperation(final Definition wsdl, final String operationName) {
    if (wsdl == null) {
        return null;
    }
    Map<QName, ?> bindings = wsdl.getBindings();
    for (Map.Entry<QName, ?> entry : bindings.entrySet()) {
        Binding binding = wsdl.getBinding((QName) entry.getKey());
        List<BindingOperation> definedOperations = binding.getBindingOperations();
        for (BindingOperation operation : definedOperations) {
            if (operation.getName().equalsIgnoreCase(operationName)) {
                return operation;
            }
        }
    }
    return null;
}
 
Example #9
Source File: APIMWSDLReader.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Returns WSDL definition from a byte content of the WSDL
 *
 * @param wsdl byte content of the WSDL document
 * @return {@link Definition} - WSDL4j definition constructed form the wsdl
 * @throws APIManagementException
 */
public Definition getWSDLDefinitionFromByteContent(byte[] wsdl, boolean readDependencies) throws APIManagementException {
    try {
        WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader();
        // switch off the verbose mode
        wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
        wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false);

        if (!readDependencies) {
            if (wsdlReader instanceof WSDLReaderImpl) {
                ((WSDLReaderImpl) wsdlReader).setIgnoreSchemaContent(true);
            }
        }

        return wsdlReader.readWSDL(null, getSecuredParsedDocumentFromContent(wsdl));
    } catch (Exception e) {
        String msg = " Error occurs when updating WSDL ";
        throw new APIManagementException(msg, e);
    }
}
 
Example #10
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void buildBindingOperation(Definition def, Binding binding,
                                   Collection<BindingOperationInfo> bindingOperationInfos) {
    BindingOperation bindingOperation = null;
    for (BindingOperationInfo bindingOperationInfo : bindingOperationInfos) {
        bindingOperation = def.createBindingOperation();
        addDocumentation(bindingOperation, bindingOperationInfo.getDocumentation());
        bindingOperation.setName(bindingOperationInfo.getName().getLocalPart());
        for (Operation operation
                : CastUtils.cast(binding.getPortType().getOperations(), Operation.class)) {
            if (operation.getName().equals(bindingOperation.getName())) {
                bindingOperation.setOperation(operation);
                break;
            }
        }
        buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
        buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
        buildBindingFault(def, bindingOperation, bindingOperationInfo.getFaults());
        addExtensibilityAttributes(def, bindingOperation, bindingOperationInfo.getExtensionAttributes());
        addExtensibilityElements(def, bindingOperation, getWSDL11Extensors(bindingOperationInfo));
        binding.addBindingOperation(bindingOperation);
    }
}
 
Example #11
Source File: WSDLRefValidator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private List<Document> getWSDLDocuments() {
    List<Document> docs = new ArrayList<>();
    try {
        docs.add(getWSDLDocument());

        if (null != importedDefinitions) {
            for (Definition d : importedDefinitions) {
                docs.add(getWSDLDocument(d.getDocumentBaseURI()));
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        // ignore
    }

    return docs;
}
 
Example #12
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void buildMessage(Message message,
                            AbstractMessageContainer messageContainer,
                            final Definition def) {
    addDocumentation(message, messageContainer.getMessageDocumentation());
    message.setQName(messageContainer.getName());
    message.setUndefined(false);
    def.addMessage(message);

    List<MessagePartInfo> messageParts = messageContainer.getMessageParts();
    Part messagePart = null;
    for (MessagePartInfo messagePartInfo : messageParts) {
        messagePart = def.createPart();
        messagePart.setName(messagePartInfo.getName().getLocalPart());
        if (messagePartInfo.isElement()) {
            messagePart.setElementName(messagePartInfo.getElementQName());
            addNamespace(messagePartInfo.getElementQName().getNamespaceURI(), def);
        } else if (messagePartInfo.getTypeQName() != null) {
            messagePart.setTypeName(messagePartInfo.getTypeQName());
            addNamespace(messagePartInfo.getTypeQName().getNamespaceURI(), def);
        }
        message.addPart(messagePart);
    }
}
 
Example #13
Source File: OperationVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static boolean accept(Scope scope,
                             Definition def,
                             XmlSchema schema,
                             AST node,
                             WSDLASTVisitor wsdlVisitor) {
    boolean result = false;
    AST node2 = node.getFirstChild();

    if (null == node2) {
       // throw whatever appropriate error
       // or do nothing and return false
    } else if (node2.getType() == IDLTokenTypes.LITERAL_oneway) {
        result = true;
    } else {
        int type = node2.getType();
        result =
            type == IDLTokenTypes.LITERAL_void
            || PrimitiveTypesVisitor.accept(node2)
            || StringVisitor.accept(node2)
            || ScopedNameVisitor.accept(scope, def, schema, node2, wsdlVisitor)
            //REVISIT, change this to be def & then schema
            || ObjectReferenceVisitor.accept(scope, schema, def, node2, wsdlVisitor);
    }
    return result;
}
 
Example #14
Source File: NamespaceConfusionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testNameNamespace() throws Exception {

    org.w3c.dom.Document doc = getWSDLDocument("NameServiceImpl");
    Element rootElement = doc.getDocumentElement();

    Definition def = getWSDLDefinition("NameServiceImpl");
    StringWriter sink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
    NodeList aonNodes =
        assertValid("//xsd:complexType[@name='ArrayOfName']/xsd:sequence/xsd:element", doc);
    Element arrayOfNameElement = (Element)aonNodes.item(0);

    String typename = arrayOfNameElement.getAttribute("type");
    String prefix = typename.split(":")[0];

    String uri = getNamespaceForPrefix(rootElement, arrayOfNameElement, prefix);
    assertNotNull(uri);
    AegisType nameType = tm.getTypeCreator().createType(Name.class);
    QName tmQname = nameType.getSchemaType();
    assertEquals(tmQname.getNamespaceURI(), uri);

}
 
Example #15
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void buildBinding(Definition definition,
                            Collection<BindingInfo> bindingInfos,
                            Collection<PortType> portTypes) {
    Binding binding = null;
    for (BindingInfo bindingInfo : bindingInfos) {
        binding = definition.createBinding();
        addDocumentation(binding, bindingInfo.getDocumentation());
        binding.setUndefined(false);
        for (PortType portType : portTypes) {
            if (portType.getQName().equals(bindingInfo.getInterface().getName())) {
                binding.setPortType(portType);
                break;
            }
        }
        binding.setQName(bindingInfo.getName());
        if (!bindingInfo.getName().getNamespaceURI().equals(definition.getTargetNamespace())) {
            addNamespace(bindingInfo.getName().getNamespaceURI(), definition);
        }
        buildBindingOperation(definition, binding, bindingInfo.getOperations());
        addExtensibilityElements(definition, binding, getWSDL11Extensors(bindingInfo));
        definition.addBinding(binding);
    }
}
 
Example #16
Source File: WSDL11ProcessorImpl.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Get endpoints defined in the provided WSDL definition.
 *
 * @param definition WSDL Definition
 * @return a Map of endpoint names and their URIs.
 * @throws APIMgtWSDLException if error occurs while reading endpoints
 */
private Map<String, String> getEndpoints(Definition definition) throws APIMgtWSDLException {
    Map serviceMap = definition.getAllServices();
    Iterator serviceItr = serviceMap.entrySet().iterator();
    Map<String, String> serviceEndpointMap = new HashMap<>();
    while (serviceItr.hasNext()) {
        Map.Entry svcEntry = (Map.Entry) serviceItr.next();
        Service svc = (Service) svcEntry.getValue();
        Map portMap = svc.getPorts();
        for (Object o : portMap.entrySet()) {
            Map.Entry portEntry = (Map.Entry) o;
            Port port = (Port) portEntry.getValue();
            List extensibilityElementList = port.getExtensibilityElements();
            for (Object extensibilityElement : extensibilityElementList) {
                String addressURI = getAddressUrl(extensibilityElement);
                serviceEndpointMap.put(port.getName(), addressURI);
            }
        }
    }
    return serviceEndpointMap;
}
 
Example #17
Source File: WSDL2UDDITest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test
public void testWSDLBindingModel() throws WSDLException, JAXBException, ConfigurationException, Exception {

	// Reading the WSDL
	Definition wsdlDefinition = rw.readWSDL("wsdl/HelloWorld.wsdl");
	String wsdlURL = wsdlDefinition.getDocumentBaseURI();
	
	Properties properties = new Properties();
	properties.put("keyDomain", "juddi.apache.org");
	WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties);
	Set<TModel> tModels = new HashSet<TModel>();
    @SuppressWarnings("unchecked")
	Map<QName,Binding> bindings= (Map<QName,Binding>) wsdlDefinition.getAllBindings();
    Set<TModel> bindingTModels = wsdl2UDDI.createWSDLBindingTModels(wsdlURL, bindings);
    tModels.addAll(bindingTModels);
    
	for (TModel tModel : tModels) {
		System.out.println("UDDI Binding TModel " + tModel.getName().getValue());
                       if (serialize)
		System.out.println(pTModel.print(tModel));
	}
	Assert.assertEquals(1,tModels.size());
}
 
Example #18
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void addExtensibilityElements(Definition def,
                                        ElementExtensible elementExtensible,
                                        List<ExtensibilityElement> extensibilityElements) {
    if (extensibilityElements != null) {
        for (ExtensibilityElement element : extensibilityElements) {
            if (element instanceof UnknownExtensibilityElement) {
                UnknownExtensibilityElement uee = (UnknownExtensibilityElement)element;
                String pfx = uee.getElement().getPrefix();
                addNamespace(pfx, element.getElementType().getNamespaceURI(), def);
            } else {
                QName qn = element.getElementType();
                addNamespace(qn.getNamespaceURI(), def);
            }
            elementExtensible.addExtensibilityElement(element);
        }
    }
}
 
Example #19
Source File: BPELPlanContext.java    From container with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the given portType is declared in the given WSDL File
 *
 * @param portType the portType to check with
 * @param wsdlFile the WSDL File to check in
 * @return true if the portType is declared in the given WSDL file
 * @throws WSDLException is thrown when either the given File is not a WSDL File or initializing the WSDL Factory
 *                       failed
 */
public boolean containsPortType(final QName portType, final Path wsdlFile) throws WSDLException {
    final WSDLFactory factory = WSDLFactory.newInstance();
    final WSDLReader reader = factory.newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    final Definition wsdlInstance = reader.readWSDL(wsdlFile.toAbsolutePath().toString());
    final Map portTypes = wsdlInstance.getAllPortTypes();
    for (final Object key : portTypes.keySet()) {
        final PortType portTypeInWsdl = (PortType) portTypes.get(key);
        if (portTypeInWsdl.getQName().getNamespaceURI().equals(portType.getNamespaceURI())
            && portTypeInWsdl.getQName().getLocalPart().equals(portType.getLocalPart())) {
            return true;
        }
    }
    return false;
}
 
Example #20
Source File: WSDLToIDLTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testBindingGenSpecifiedFile() throws Exception {

    String[] cmdArgs = {"-corba", "-i", "BasePortType",
                        "-w", "simpleList-corba_gen.wsdl",
                        "-d", output.toString(),
                        getClass().getResource("/wsdl/simpleList.wsdl").toString()};
    String error = execute(cmdArgs);
    assertNull("WSDLToIDL Failed", error);

    Path f = output.resolve("simpleList-corba_gen.wsdl");
    assertTrue("simpleList-corba_gen.wsdl should be generated", Files.exists(f));

    WSDLToProcessor proc = new WSDLToProcessor();
    try {
        proc.parseWSDL(f.toString());
        Definition model = proc.getWSDLDefinition();
        assertNotNull("WSDL Definition Should not be Null", model);
        QName bindingName = new QName("http://schemas.apache.org/tests", "BaseCORBABinding");
        assertNotNull("Binding Node not found in WSDL", model.getBinding(bindingName));
    } catch (Exception e) {
        fail("WSDLToIDL generated an invalid simpleList-corba.wsdl");
    }
}
 
Example #21
Source File: AegisTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testAegisBasic() throws Exception {
    final String sei = org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI.class.getName();
    String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/aegis.wsdl", "-verbose", "-d",
                                  output.getPath(), "-s", output.getPath(),
                                  "-frontend", "jaxws", "-databinding", "aegis",
                                  "-client", "-server", sei};
    File wsdlFile = null;
    wsdlFile = outputFile("aegis.wsdl");
    JavaToWS.main(args);
    assertTrue("wsdl is not generated", wsdlFile.exists());

    WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    Definition def = reader.readWSDL(wsdlFile.toURI().toURL().toString());
    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
    assertValid("//xsd:element[@type='ns0:Something']", wsdl);
}
 
Example #22
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static boolean isPortTypeExisted(Definition wsdlDefinition, QName name) {
    Map<QName, PortType>  portTypes = CastUtils.cast(wsdlDefinition.getAllPortTypes());
    if (portTypes == null || portTypes.isEmpty()) {
        return false;
    }
    String existPortTypeName = null;
    PortType portType = null;
    try {
        for (Entry<QName, PortType> entry : portTypes.entrySet()) {
            existPortTypeName = entry.getKey().getLocalPart();
            if (name.getLocalPart().contains(existPortTypeName)) {
                portType = entry.getValue();
                break;
            }
        }
    } catch (Exception e) {
        portType = null;
    }
    return portType != null;
}
 
Example #23
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static boolean isBindingExisted(Definition wsdlDefinition, QName name) {
    Map<QName, Binding> bindings = CastUtils.cast(wsdlDefinition.getAllBindings());
    Binding binding = null;
    if (bindings == null || bindings.isEmpty()) {
        return false;
    }
    try {
        for (Entry<QName, Binding> entry : bindings.entrySet()) {
            if (entry.getKey().getLocalPart().contains(name.getLocalPart())) {
                binding = entry.getValue();
                break;
            }
        }
    } catch (Exception e) {
        binding = null;
    }
    return binding != null;
}
 
Example #24
Source File: SimpleTypeSpecVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public SimpleTypeSpecVisitor(Scope scope,
                             Definition defn,
                             XmlSchema schemaRef,
                             WSDLASTVisitor wsdlVisitor,
                             AST identifierNodeRef) {
    super(scope, defn, schemaRef, wsdlVisitor);
    identifierNode = identifierNodeRef;
}
 
Example #25
Source File: WSDLASTVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean writeSchema(XmlSchema schemaRef, Writer writer) throws Exception  {
    //REVISIT, it should be easier to  write out the schema directly, but currently,
    //the XmlSchemaSerializer throws a NullPointerException, when setting up namespaces!!!
    //schemaRef.write(writer);
    Definition defn = manager.createWSDLDefinition(schemaRef.getTargetNamespace());
    manager.attachSchemaToWSDL(defn, schemaRef, true);
    writeSchemaDefinition(defn, writer);
    return true;
}
 
Example #26
Source File: WSDLGetUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Deprecated
protected void updateDoc(Document doc,
                         String base,
                         Map<String, Definition> mp,
                         Map<String, SchemaReference> smp,
                         Message message,
                         String xsd,
                         String wsdl) {
    updateDoc(doc, base, mp, smp, message, xsd != null ? xsd : wsdl);
}
 
Example #27
Source File: BPEL_020_IntegrationTest.java    From juddi with Apache License 2.0 5 votes vote down vote up
@Test
public void parseWSDL_PortTypeTModels() throws WSDLException, Exception {

        Definition wsdlDefinition = rw.readWSDL("uddi_data/bpel/riftsaw/bpel-technote.wsdl");
        @SuppressWarnings("unchecked")
        Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes();
        String ns = wsdlDefinition.getTargetNamespace();
        logger.info("Namespace: " + ns);

        boolean foundInterfaceOfTravelAgent=false;
        boolean foundInterfaceOfCustomer=false;
  
        Iterator<QName> iterator = portTypes.keySet().iterator();
        while (iterator.hasNext()) {
                QName qName = iterator.next();
                String nsp = qName.getNamespaceURI();
                String localpart = qName.getLocalPart();
                logger.info("Namespace: " + nsp);
                logger.info("LocalPart: " + localpart);
                if (localpart.equals("InterfaceOfTravelAgent"))
                        foundInterfaceOfTravelAgent=true;
                if (localpart.equals("InterfaceOfCustomer"))
                        foundInterfaceOfCustomer=true;
        }
        org.junit.Assert.assertTrue("InterfaceOfCustomer wasn't found, wsdl parsing error", foundInterfaceOfCustomer);
        org.junit.Assert.assertTrue("InterfaceOfTravelAgent wasn't found, wsdl parsing error", foundInterfaceOfTravelAgent);
}
 
Example #28
Source File: WSDLCorbaFactoryImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new instance of a Definition, with an instance of a
 * PopulatedExtensionRegistry as its ExtensionRegistry.
 */
public Definition newDefinition() {
    Definition def = factory.newDefinition();
    ExtensionRegistry extReg = newPopulatedExtensionRegistry();
    def.setExtensionRegistry(extReg);
    return def;
}
 
Example #29
Source File: APIMWSDLReader.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
    * Update WSDL 1.0 service definitions saved in registry
    *
    * @param wsdl 	byte array of registry content
 * @param api 	API object
 * @return 		the OMElemnt of the new WSDL content
 * @throws APIManagementException
    */
public OMElement updateWSDL(byte[] wsdl, API api) throws APIManagementException {

	try {
		// Generate wsdl document from registry data
		WSDLReader wsdlReader = getWsdlFactoryInstance().newWSDLReader();
		// switch off the verbose mode
		wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
		wsdlReader.setFeature(JAVAX_WSDL_IMPORT_DOCUMENTS, false);

		if (wsdlReader instanceof WSDLReaderImpl) {
		    ((WSDLReaderImpl) wsdlReader).setIgnoreSchemaContent(true);
		}

		Definition wsdlDefinition = wsdlReader.readWSDL(null, getSecuredParsedDocumentFromContent(wsdl));

		// Update transports
		setServiceDefinition(wsdlDefinition, api);

		WSDLWriter writer = getWsdlFactoryInstance().newWSDLWriter();
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		writer.writeWSDL(wsdlDefinition, byteArrayOutputStream);
		ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( byteArrayOutputStream.toByteArray());
		return APIUtil.buildOMElement(byteArrayInputStream);

	} catch (Exception e) {
		String msg = " Error occurs when updating WSDL ";
		log.error(msg);
		throw new APIManagementException(msg, e);
	}
}
 
Example #30
Source File: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieves all the operations defined in the provided WSDL definition.
 *
 * @param definition WSDL Definition
 * @return a set of {@link WSDLOperation} defined in the provided WSDL definition
 */
private Set<WSDLSOAPOperation> getSoapBindingOperations(Definition definition) throws APIMgtWSDLException {
    Set<WSDLSOAPOperation> allOperations = new HashSet<>();
    for (Object bindingObj : definition.getAllBindings().values()) {
        if (bindingObj instanceof Binding) {
            Binding binding = (Binding) bindingObj;
            Set<WSDLSOAPOperation> operations = getSOAPBindingOperations(binding);
            allOperations.addAll(operations);
        }
    }
    return allOperations;
}