Search in sources :

Example 11 with SchemaInfo

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

the class CorbaUtils method isElementFormQualified.

// Change this method to access the XmlSchemaCollection.
public static boolean isElementFormQualified(ServiceInfo serviceInfo, String uri) {
    if (uri != null) {
        SchemaInfo schemaInfo = serviceInfo.getSchema(uri);
        if (schemaInfo != null) {
            return schemaInfo.isElementFormQualified();
        }
        Iterator<SchemaInfo> it = serviceInfo.getSchemas().iterator();
        while (it.hasNext()) {
            XmlSchema schema = it.next().getSchema();
            return isElementFormQualified(schema, uri);
        }
    }
    return false;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Example 12 with SchemaInfo

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

the class JavascriptGetInterceptor method writeResponse.

private void writeResponse(URI uri, Map<String, String> map, OutputStream os, Endpoint serverEndpoint) {
    OutputStreamWriter writer = new OutputStreamWriter(os, UTF8);
    if (!map.containsKey(NO_UTILS_QUERY_KEY)) {
        writeUtilsToResponseStream(JavascriptGetInterceptor.class, os);
    }
    if (map.containsKey(CODE_QUERY_KEY)) {
        ServiceInfo serviceInfo = serverEndpoint.getService().getServiceInfos().get(0);
        Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
        // we need to move this to the bus.
        BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo, serverEndpoint);
        NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo.getXmlSchemaCollection());
        try {
            for (SchemaInfo schema : schemata) {
                SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo.getXmlSchemaCollection(), prefixManager, nameManager);
                String allThatJavascript = builder.generateCodeForSchema(schema.getSchema());
                writer.append(allThatJavascript);
            }
            ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo, serverEndpoint.getEndpointInfo().getAddress(), prefixManager, nameManager);
            serviceBuilder.walk();
            String serviceJavascript = serviceBuilder.getCode();
            writer.append(serviceJavascript);
            writer.flush();
        } catch (IOException e) {
            throw new UncheckedException(e);
        }
    } else {
        throw new RuntimeException("Invalid query " + uri.toString());
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) ServiceJavascriptBuilder(org.apache.cxf.javascript.service.ServiceJavascriptBuilder) UncheckedException(org.apache.cxf.common.i18n.UncheckedException) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) SchemaJavascriptBuilder(org.apache.cxf.javascript.types.SchemaJavascriptBuilder)

Example 13 with SchemaInfo

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

the class JavascriptTestUtilities method loadJavascriptForService.

public void loadJavascriptForService(ServiceInfo serviceInfo) {
    Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
    BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo);
    NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo.getXmlSchemaCollection());
    for (SchemaInfo schema : schemata) {
        SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo.getXmlSchemaCollection(), prefixManager, nameManager);
        String allThatJavascript = builder.generateCodeForSchema(schema.getSchema());
        readStringIntoRhino(allThatJavascript, schema.toString() + ".js");
    }
    ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo, null, prefixManager, nameManager);
    serviceBuilder.walk();
    String serviceJavascript = serviceBuilder.getCode();
    readStringIntoRhino(serviceJavascript, serviceInfo.getName() + ".js");
}
Also used : ServiceJavascriptBuilder(org.apache.cxf.javascript.service.ServiceJavascriptBuilder) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) SchemaJavascriptBuilder(org.apache.cxf.javascript.types.SchemaJavascriptBuilder)

Example 14 with SchemaInfo

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

the class JaxWsServiceFactoryBeanTest method testWrappedDocLit.

@Test
public void testWrappedDocLit() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    Bus bus = getBus();
    bean.setBus(bus);
    bean.setServiceClass(org.apache.hello_world_doc_lit.Greeter.class);
    Service service = bean.create();
    ServiceInfo si = service.getServiceInfos().get(0);
    InterfaceInfo intf = si.getInterface();
    assertEquals(4, intf.getOperations().size());
    String ns = si.getName().getNamespaceURI();
    assertEquals("http://apache.org/hello_world_doc_lit", ns);
    OperationInfo greetMeOp = intf.getOperation(new QName(ns, "greetMe"));
    assertNotNull(greetMeOp);
    assertEquals("greetMe", greetMeOp.getInput().getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_doc_lit", greetMeOp.getInput().getName().getNamespaceURI());
    List<MessagePartInfo> messageParts = greetMeOp.getInput().getMessageParts();
    assertEquals(1, messageParts.size());
    MessagePartInfo inMessagePart = messageParts.get(0);
    assertEquals("http://apache.org/hello_world_doc_lit", inMessagePart.getName().getNamespaceURI());
    assertEquals("http://apache.org/hello_world_doc_lit/types", inMessagePart.getElementQName().getNamespaceURI());
    // test output
    messageParts = greetMeOp.getOutput().getMessageParts();
    assertEquals(1, messageParts.size());
    assertEquals("greetMeResponse", greetMeOp.getOutput().getName().getLocalPart());
    MessagePartInfo outMessagePart = messageParts.get(0);
    // assertEquals("result", outMessagePart.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_doc_lit", outMessagePart.getName().getNamespaceURI());
    assertEquals("http://apache.org/hello_world_doc_lit/types", outMessagePart.getElementQName().getNamespaceURI());
    OperationInfo greetMeOneWayOp = si.getInterface().getOperation(new QName(ns, "greetMeOneWay"));
    assertEquals(1, greetMeOneWayOp.getInput().getMessageParts().size());
    assertNull(greetMeOneWayOp.getOutput());
    Collection<SchemaInfo> schemas = si.getSchemas();
    assertEquals(1, schemas.size());
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 15 with SchemaInfo

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

the class WSDLGetUtils method updateWSDLKeyDefinition.

/**
 * Create a wsdl Definition object from the endpoint information and register
 * it in the local data structure for future reference.
 *
 * @param bus CXF's hub for access to internal constructs
 * @param mp  a map of known wsdl Definition objects
 * @param message
 * @param smp a map of known xsd SchemaReference objects
 * @param base the request URL
 * @param endpointInfo information for a web service 'port' inside of a service
 * @throws WSDLException
 */
protected void updateWSDLKeyDefinition(Bus bus, Map<String, Definition> mp, Message message, Map<String, SchemaReference> smp, String base, EndpointInfo endpointInfo) throws WSDLException {
    if (!mp.containsKey("")) {
        ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, endpointInfo.getService());
        builder.setUseSchemaImports(MessageUtils.getContextualBoolean(message, WSDL_CREATE_IMPORTS, false));
        // base file name is ignored if createSchemaImports == false!
        builder.setBaseFileName(endpointInfo.getService().getName().getLocalPart());
        Definition def = builder.build(new HashMap<String, SchemaInfo>());
        mp.put("", def);
        updateDefinition(bus, def, mp, smp, base, "", "");
    }
}
Also used : Definition(javax.wsdl.Definition) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) SchemaInfo(org.apache.cxf.service.model.SchemaInfo)

Aggregations

SchemaInfo (org.apache.cxf.service.model.SchemaInfo)42 XmlSchema (org.apache.ws.commons.schema.XmlSchema)17 QName (javax.xml.namespace.QName)11 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)11 Element (org.w3c.dom.Element)10 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)7 XMLStreamException (javax.xml.stream.XMLStreamException)7 Message (org.apache.cxf.common.i18n.Message)6 FileNotFoundException (java.io.FileNotFoundException)5 URL (java.net.URL)5 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)5 InputSource (org.xml.sax.InputSource)5 SAXException (org.xml.sax.SAXException)5 SAXParseException (org.xml.sax.SAXParseException)5 File (java.io.File)4 Method (java.lang.reflect.Method)4 HashSet (java.util.HashSet)4 SchemaCollection (org.apache.cxf.common.xmlschema.SchemaCollection)4