Search in sources :

Example 26 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class InterfaceMapperTest method testMap.

@Test
public void testMap() throws Exception {
    InterfaceInfo interfaceInfo = new InterfaceInfo(new ServiceInfo(), new QName("http://apache.org/hello_world_soap_http", "interfaceTest"));
    ToolContext context = new ToolContext();
    context.put(ToolConstants.CFG_WSDLURL, "http://localhost/?wsdl");
    JavaInterface intf = new InterfaceMapper(context).map(interfaceInfo);
    assertNotNull(intf);
    assertEquals("interfaceTest", intf.getWebServiceName());
    assertEquals("InterfaceTest", intf.getName());
    assertEquals("http://apache.org/hello_world_soap_http", intf.getNamespace());
    assertEquals("org.apache.hello_world_soap_http", intf.getPackageName());
    assertEquals("http://localhost/?wsdl", intf.getLocation());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) QName(javax.xml.namespace.QName) ToolContext(org.apache.cxf.tools.common.ToolContext) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Example 27 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class PortTypeProcessor method process.

public void process(ServiceInfo serviceInfo) throws ToolException {
    operationMap.clear();
    JavaModel jmodel = context.get(JavaModel.class);
    InterfaceInfo interfaceInfo = serviceInfo.getInterface();
    if (interfaceInfo == null) {
        return;
    }
    JavaInterface intf = getInterface(context, serviceInfo, interfaceInfo);
    intf.setJavaModel(jmodel);
    Element handler = (Element) context.get(ToolConstants.HANDLER_CHAIN);
    intf.setHandlerChains(handler);
    Collection<OperationInfo> operations = interfaceInfo.getOperations();
    for (OperationInfo operation : operations) {
        if (isOverloading(operation.getName())) {
            LOG.log(Level.WARNING, "SKIP_OVERLOADED_OPERATION", operation.getName());
            continue;
        }
        OperationProcessor operationProcessor = new OperationProcessor(context);
        operationProcessor.process(intf, operation);
    }
    jmodel.setLocation(intf.getLocation());
    jmodel.addInterface(intf.getName(), intf);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) JavaModel(org.apache.cxf.tools.common.model.JavaModel) Element(org.w3c.dom.Element) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 28 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class PortTypeProcessor method processClassNames.

public void processClassNames(ServiceInfo serviceInfo) throws ToolException {
    InterfaceInfo interfaceInfo = serviceInfo.getInterface();
    if (interfaceInfo == null) {
        return;
    }
    getInterface(context, serviceInfo, interfaceInfo);
}
Also used : InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 29 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class WSDLToJavaContainer method processWsdl.

private void processWsdl() {
    validate(context);
    FrontEndProfile frontend = context.get(FrontEndProfile.class);
    if (frontend == null) {
        throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
    }
    WSDLConstants.WSDLVersion version = getWSDLVersion();
    String wsdlURL = (String) context.get(ToolConstants.CFG_WSDLURL);
    @SuppressWarnings("unchecked") List<ServiceInfo> serviceList = (List<ServiceInfo>) context.get(ToolConstants.SERVICE_LIST);
    if (serviceList == null) {
        serviceList = new ArrayList<>();
        // Build the ServiceModel from the WSDLModel
        if (version == WSDLConstants.WSDLVersion.WSDL11) {
            AbstractWSDLBuilder builder = frontend.getWSDLBuilder();
            builder.setContext(context);
            builder.setBus(getBus());
            context.put(Bus.class, getBus());
            wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
            builder.build(wsdlURL);
            builder.customize();
            Definition definition = builder.getWSDLModel();
            context.put(Definition.class, definition);
            builder.validate(definition);
            WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
            if (context.isVerbose()) {
                serviceBuilder.setUnwrapLogLevel(Level.INFO);
            }
            serviceBuilder.setIgnoreUnknownBindings(true);
            String allowRefs = (String) context.get(ToolConstants.CFG_ALLOW_ELEMENT_REFS);
            if (!StringUtils.isEmpty(allowRefs) || context.optionSet(ToolConstants.CFG_ALLOW_ELEMENT_REFS)) {
                if (allowRefs.length() > 0 && allowRefs.charAt(0) == '=') {
                    allowRefs = allowRefs.substring(1);
                }
                if (StringUtils.isEmpty(allowRefs)) {
                    allowRefs = "true";
                }
                serviceBuilder.setAllowElementRefs(Boolean.valueOf(allowRefs));
            }
            String serviceName = (String) context.get(ToolConstants.CFG_SERVICENAME);
            if (serviceName != null) {
                List<ServiceInfo> services = serviceBuilder.buildServices(definition, getServiceQName(definition));
                serviceList.addAll(services);
            } else if (definition.getServices().size() > 0) {
                serviceList = serviceBuilder.buildServices(definition);
            } else {
                serviceList = serviceBuilder.buildMockServices(definition);
            }
            // remove definition from cache so that won't fail when encounter same wsdl file
            // name but different wsdl content(CXF-3340)
            getBus().getExtension(WSDLManager.class).removeDefinition(definition);
        } else {
        // TODO: wsdl2.0 support
        }
    }
    context.put(ToolConstants.SERVICE_LIST, serviceList);
    Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();
    ServiceInfo service0 = serviceList.get(0);
    SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
    context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
    context.put(ToolConstants.PORTTYPE_MAP, interfaces);
    context.put(ClassCollector.class, createClassCollector());
    Processor processor = frontend.getProcessor();
    if (processor instanceof ClassNameProcessor) {
        processor.setEnvironment(context);
        for (ServiceInfo service : serviceList) {
            context.put(ServiceInfo.class, service);
            ((ClassNameProcessor) processor).processClassNames();
            context.put(ServiceInfo.class, null);
        }
    }
    if (context.optionSet(ToolConstants.CFG_NO_TYPES)) {
        context.remove(ToolConstants.CFG_TYPES);
        context.remove(ToolConstants.CFG_ALL);
        context.remove(ToolConstants.CFG_COMPILE);
    }
    generateTypes();
    if (context.getErrorListener().getErrorCount() > 0) {
        return;
    }
    for (ServiceInfo service : serviceList) {
        context.put(ServiceInfo.class, service);
        if (context.basicValidateWSDL()) {
            validate(service);
        }
        if (context.getErrorListener().getErrorCount() == 0) {
            // Build the JavaModel from the ServiceModel
            processor.setEnvironment(context);
            processor.process();
        }
    }
    if (context.getErrorListener().getErrorCount() > 0) {
        return;
    }
    if (context.optionSet(ToolConstants.CFG_CLIENT_JAR)) {
        enforceWSDLLocation(context);
    }
    if (!isSuppressCodeGen()) {
        // Generate artifacts
        for (FrontEndGenerator generator : frontend.getGenerators()) {
            generator.generate(context);
        }
    }
    context.remove(ToolConstants.SERVICE_LIST);
    // Build projects: compile classes and copy resources etc.
    if (context.optionSet(ToolConstants.CFG_COMPILE)) {
        new ClassUtils().compile(context);
    }
    if (context.isExcludeNamespaceEnabled()) {
        try {
            removeExcludeFiles();
        } catch (IOException e) {
            throw new ToolException(e);
        }
    }
    if (context.optionSet(ToolConstants.CFG_CLIENT_JAR)) {
        processClientJar(context);
    }
}
Also used : AbstractWSDLBuilder(org.apache.cxf.tools.wsdlto.core.AbstractWSDLBuilder) ClassNameProcessor(org.apache.cxf.tools.common.ClassNameProcessor) Processor(org.apache.cxf.tools.common.Processor) Message(org.apache.cxf.common.i18n.Message) Definition(javax.wsdl.Definition) IOException(java.io.IOException) ClassUtils(org.apache.cxf.tools.common.ClassUtils) FrontEndProfile(org.apache.cxf.tools.wsdlto.core.FrontEndProfile) LinkedHashMap(java.util.LinkedHashMap) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) WSDLConstants(org.apache.cxf.wsdl.WSDLConstants) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) FrontEndGenerator(org.apache.cxf.tools.common.FrontEndGenerator) WSDLManager(org.apache.cxf.wsdl.WSDLManager) ClassNameProcessor(org.apache.cxf.tools.common.ClassNameProcessor) List(java.util.List) ArrayList(java.util.ArrayList) ToolException(org.apache.cxf.tools.common.ToolException) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection)

Example 30 with InterfaceInfo

use of org.apache.cxf.service.model.InterfaceInfo in project cxf by apache.

the class InterfaceMapperTest method testMapWithUniqueWsdlLoc.

@Test
public void testMapWithUniqueWsdlLoc() throws Exception {
    InterfaceInfo interfaceInfo = new InterfaceInfo(new ServiceInfo(), new QName("http://apache.org/hello_world_soap_http", "interfaceTest"));
    ToolContext context = new ToolContext();
    context.put(ToolConstants.CFG_WSDLURL, "http://localhost/?wsdl");
    context.put(ToolConstants.CFG_WSDLLOCATION, "/foo/blah.wsdl");
    JavaInterface intf = new InterfaceMapper(context).map(interfaceInfo);
    assertNotNull(intf);
    assertEquals("interfaceTest", intf.getWebServiceName());
    assertEquals("InterfaceTest", intf.getName());
    assertEquals("http://apache.org/hello_world_soap_http", intf.getNamespace());
    assertEquals("org.apache.hello_world_soap_http", intf.getPackageName());
    assertEquals("/foo/blah.wsdl", intf.getLocation());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) JavaInterface(org.apache.cxf.tools.common.model.JavaInterface) QName(javax.xml.namespace.QName) ToolContext(org.apache.cxf.tools.common.ToolContext) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Test(org.junit.Test)

Aggregations

InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)52 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)32 OperationInfo (org.apache.cxf.service.model.OperationInfo)30 QName (javax.xml.namespace.QName)25 Test (org.junit.Test)23 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)21 Service (org.apache.cxf.service.Service)20 Endpoint (org.apache.cxf.endpoint.Endpoint)19 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)17 BindingInfo (org.apache.cxf.service.model.BindingInfo)16 Method (java.lang.reflect.Method)15 ArrayList (java.util.ArrayList)10 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)9 Bus (org.apache.cxf.Bus)8 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)7 List (java.util.List)5 WebService (javax.jws.WebService)5 MessageInfo (org.apache.cxf.service.model.MessageInfo)5 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)5