use of javax.wsdl.Definition in project cxf by apache.
the class AbstractAegisTest method getWSDLDocuments.
protected Collection<Document> getWSDLDocuments(String string) throws WSDLException {
WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
Collection<Document> docs = new ArrayList<>();
Definition definition = getWSDLDefinition(string);
if (definition == null) {
return null;
}
docs.add(writer.getDocument(definition));
for (Import wsdlImport : getImports(definition)) {
docs.add(writer.getDocument(wsdlImport.getDefinition()));
}
return docs;
}
use of javax.wsdl.Definition in project cxf by apache.
the class ServiceImpl method initializePorts.
private void initializePorts() {
try {
Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
javax.wsdl.Service serv = def.getService(serviceName);
if (serv == null) {
throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
}
Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
for (Port port : wsdlports.values()) {
QName name = new QName(serviceName.getNamespaceURI(), port.getName());
String address = null;
String bindingID = null;
List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
} else if (e instanceof SOAP12Binding) {
bindingID = SOAPBinding.SOAP12HTTP_BINDING;
} else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
}
}
extensions = CastUtils.cast(port.getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapAddress) {
address = ((SoapAddress) e).getLocationURI();
} else if (e instanceof AddressType) {
address = ((AddressType) e).getLocation();
} else if (e instanceof SOAP12Address) {
address = ((SOAP12Address) e).getLocationURI();
} else if (e instanceof SOAPAddress) {
address = ((SOAPAddress) e).getLocationURI();
} else if (e instanceof HTTPAddress) {
address = ((HTTPAddress) e).getLocationURI();
}
}
addPort(name, bindingID, address);
}
} catch (WebServiceException e) {
throw e;
} catch (Throwable e) {
if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, e.getLocalizedMessage(), e);
}
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
Service service = sf.create();
for (ServiceInfo si : service.getServiceInfos()) {
for (EndpointInfo ei : si.getEndpoints()) {
String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
addPort(ei.getName(), bindingID, ei.getAddress());
}
}
}
}
use of javax.wsdl.Definition in project cxf by apache.
the class ParameterMappingTest method testNamedParameter.
@Test
public void testNamedParameter() throws Exception {
Node doc = getWSDLDocument("ArrayService");
Definition def = getWSDLDefinition("ArrayService");
StringWriter sink = new StringWriter();
WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
assertValid("/wsdl:definitions/wsdl:types/" + "xsd:schema[@targetNamespace= 'http://services.aegis.cxf.apache.org']" + "/xsd:complexType[@name='verifyCustomParamName']" + "/xsd:sequence" + "/xsd:element[@name='custom']", doc);
}
use of javax.wsdl.Definition in project cxf by apache.
the class NamespaceConfusionTest method testNameNamespace.
@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);
}
use of javax.wsdl.Definition in project cxf by apache.
the class ExplicitPrefixTest method testOnePrefix.
@Test
public void testOnePrefix() throws Exception {
Map<String, String> mappings = new HashMap<>();
mappings.put(URN_AEGIS_NAMESPACE_TEST, AEGIS_TEST_NAMESPACE_PREFIX_XYZZY);
ServiceAndMapping serviceAndMapping = setupService(NameServiceImpl.class, mappings);
Definition def = getWSDLDefinition("NameServiceImpl");
StringWriter wsdlSink = new StringWriter();
WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, wsdlSink);
org.w3c.dom.Document wsdlDoc = getWSDLDocument("NameServiceImpl");
Element rootElement = wsdlDoc.getDocumentElement();
addNamespace(AEGIS_TEST_NAMESPACE_PREFIX_XYZZY, URN_AEGIS_NAMESPACE_TEST);
assertXPathEquals("//namespace::xyzzy", URN_AEGIS_NAMESPACE_TEST, rootElement);
Element nameSchema = (Element) assertValid("//xsd:schema[@targetNamespace='urn:aegis:namespace:test']", rootElement).item(0);
Map<String, String> namePrefixes = getNodeNamespaceDeclarations(nameSchema);
// there should be no TNS prefix, since the TNS namespace is explicitly
// xyzzy.
assertFalse(namePrefixes.containsKey("tns"));
Element serviceSchema = (Element) assertValid("//xsd:schema[@targetNamespace='http://impl.namespaces.aegis.cxf.apache.org']", rootElement).item(0);
Map<String, String> servicePrefixes = getNodeNamespaceDeclarations(serviceSchema);
String testPrefix = lookupPrefix(servicePrefixes, URN_AEGIS_NAMESPACE_TEST);
assertEquals(AEGIS_TEST_NAMESPACE_PREFIX_XYZZY, testPrefix);
serviceAndMapping.getServer().destroy();
}
Aggregations