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;
}
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());
}
}
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");
}
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());
}
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, "", "");
}
}
Aggregations