public static List<Element> getWSDLs(Server server) { Message message = PhaseInterceptorChain.getCurrentMessage(); message.put(WSDLGetUtils.AUTO_REWRITE_ADDRESS_ALL, true); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); List<Element> ret = new LinkedList<>(); for (String id : utils.getWSDLIds(message, base, ctxUri, info)) { Map<String, String> params = new HashMap<>(); params.put("wsdl", id); ret.add(utils.getDocument(message, base, params, ctxUri, info).getDocumentElement()); } return ret; }
public Map<String, String> getSchemaLocations(Message message, String base, String ctxUri, EndpointInfo endpointInfo) { Map<String, String> params = new HashMap<>(); params.put("wsdl", ""); getDocument(message, base, params, ctxUri, endpointInfo); Map<String, SchemaReference> mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService() .getProperty(SCHEMAS_KEY)); Map<String, String> schemas = new HashMap<>(); for (Map.Entry<String, SchemaReference> ent : mp.entrySet()) { params.clear(); params.put("xsd", ent.getKey()); Document doc = getDocument(message, base, params, ctxUri, endpointInfo); schemas.put(doc.getDocumentElement().getAttribute("targetNamespace"), buildUrl(base, ctxUri, "xsd=" + ent.getKey())); } return schemas; }
String parentResolved) { OASISCatalogManager catalogs = OASISCatalogManager.getCatalogManager(bus); String start = findSchemaLocation(doneSchemas, schemaReference, docBase); String origLocation = schemaReference.getSchemaLocationURI(); String resolvedSchemaLocation = resolveWithCatalogs(catalogs, start, base); if (resolvedSchemaLocation == null) { resolvedSchemaLocation = resolveWithCatalogs(catalogs, schemaReference.getSchemaLocationURI(), base); resolvedSchemaLocation = resolveRelativePath(parentResolved, decodedOrigLocation); doneSchemas.put(resolvedSchemaLocation, schemaReference); updateSchemaImports(bus, schemaReference.getReferencedSchema(), start, doneSchemas, base, resolvedSchemaLocation); String p = getAndSaveRelativeSchemaLocationIfCatalogResolved(doneSchemas, resolvedSchemaLocation, schema, schemaReference); updateSchemaImports(bus, schemaReference.getReferencedSchema(), p, doneSchemas, base, resolvedSchemaLocation);
def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation); new WSDLGetUtils().updateWSDLPublishedEndpointAddress(def, endpointInfo);
public static List<Element> getSchemas(Server server, String id) { Message message = PhaseInterceptorChain.getCurrentMessage(); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); Map<String, String> locs = utils.getSchemaLocations(message, base, ctxUri, info); List<Element> ret = new LinkedList<>(); for (Map.Entry<String, String> xsd : locs.entrySet()) { if (StringUtils.isEmpty(id) || id.equals(xsd.getKey())) { String query = xsd.getValue().substring(xsd.getValue().indexOf('?') + 1); Map<String, String> params = UrlUtils.parseQueryString(query); ret.add(utils.getDocument(message, base, params, ctxUri, info).getDocumentElement()); } } return ret; }
private Document getDocument(Message message, String base, Map<String, String> params, String ctxUri) { // cannot have two wsdl's being generated for the same endpoint at the same // time as the addresses may get mixed up // For WSDL's the WSDLWriter does not share any state between documents. // For XSD's, the WSDLGetUtils makes a copy of any XSD schema documents before updating // any addresses and returning them, so for both WSDL and XSD this is the only part that needs // to be synchronized. synchronized (message.getExchange().getEndpoint()) { return new WSDLGetUtils().getDocument(message, base, params, ctxUri, message.getExchange().getEndpoint().getEndpointInfo()); } }
public static Map<String, String> getSchemaLocations(Server server) { Message message = PhaseInterceptorChain.getCurrentMessage(); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); return utils.getSchemaLocations(message, base, ctxUri, info); }
public Set<String> getWSDLIds(Message message, String base, String ctxUri, EndpointInfo endpointInfo) { Map<String, String> params = new HashMap<>(); params.put("wsdl", ""); getDocument(message, base, params, ctxUri, endpointInfo); Map<String, Definition> mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService() .getProperty(WSDLS_KEY)); return mp.keySet(); } public Map<String, String> getSchemaLocations(Message message,
utils = new WSDLGetUtils(); message.put(WSDLGetUtils.class, utils);
for (Element el : elementList) { String sl = el.getAttribute("schemaLocation"); sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI()); if (sl != null) { el.setAttribute("schemaLocation", sl); for (Element el : elementList) { String sl = el.getAttribute("schemaLocation"); sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI()); if (sl != null) { el.setAttribute("schemaLocation", sl); for (Element el : elementList) { String sl = el.getAttribute("schemaLocation"); sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI()); if (sl != null) { el.setAttribute("schemaLocation", sl); String sl = el.getAttribute("location"); try { sl = getLocationURI(sl, xsdWsdlPar); } catch (URISyntaxException e) { String basePath = (String) message.get("http.base.path"); for (Element el : portList) { rewriteAddressProtocolHostPort(base, el, basePath, "http://schemas.xmlsoap.org/wsdl/soap/"); rewriteAddressProtocolHostPort(base, el, basePath, "http://schemas.xmlsoap.org/wsdl/soap12/"); if (name.equals(message.getExchange().getEndpoint().getEndpointInfo()
String resolvedSchemaLocation = resolveWithCatalogs(catalogs, start, base); } catch (MalformedURLException e) { try { start = getLocationURI(start, docBase); decodedStart = URLDecoder.decode(start, "utf-8"); } catch (Exception e1) { done.put(imp.getDefinition().getDocumentBaseURI(), imp.getDefinition()); updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, start, null); done.put(imp.getDefinition().getDocumentBaseURI(), imp.getDefinition()); updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, start, resolvedSchemaLocation); : CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class)) { if (el instanceof Schema) { updateSchemaImports(bus, (Schema)el, docBase, doneSchemas, base, parentResolvedLocation);
private String findSchemaLocation(Map<String, SchemaReference> doneSchemas, SchemaReference imp, String docBase) { String schemaLocationURI = imp.getSchemaLocationURI(); if (docBase != null && schemaLocationURI != null) { try { schemaLocationURI = getLocationURI(schemaLocationURI, docBase); } catch (Exception e) { //ignore } } if (imp.getReferencedSchema() != null) { for (Map.Entry<String, SchemaReference> e : doneSchemas.entrySet()) { if ((e.getValue().getReferencedSchema().getElement() == imp.getReferencedSchema().getElement()) && schemaLocationURI.equals(e.getKey())) { doneSchemas.put(schemaLocationURI, imp); imp.setSchemaLocationURI(e.getKey()); return e.getKey(); } } } return schemaLocationURI; }
public static List<Element> getSchemas(Server server, String id) { Message message = PhaseInterceptorChain.getCurrentMessage(); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); Map<String, String> locs = utils.getSchemaLocations(message, base, ctxUri, info); List<Element> ret = new LinkedList<>(); for (Map.Entry<String, String> xsd : locs.entrySet()) { if (StringUtils.isEmpty(id) || id.equals(xsd.getKey())) { String query = xsd.getValue().substring(xsd.getValue().indexOf('?') + 1); Map<String, String> params = UrlUtils.parseQueryString(query); ret.add(utils.getDocument(message, base, params, ctxUri, info).getDocumentElement()); } } return ret; }
@Test public void testNewDocumentIsCreatedForEachWsdlRequest() { JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new StuffImpl()); factory.setAddress("http://localhost:" + PORT + "/Stuff"); Server server = factory.create(); try { Message message = new MessageImpl(); Exchange exchange = new ExchangeImpl(); exchange.put(Bus.class, getBus()); exchange.put(Service.class, server.getEndpoint().getService()); exchange.put(Endpoint.class, server.getEndpoint()); message.setExchange(exchange); Map<String, String> map = UrlUtils.parseQueryString("wsdl"); String baseUri = "http://localhost:" + PORT + "/Stuff"; String ctx = "/Stuff"; WSDLGetUtils utils = new WSDLGetUtils(); Document doc = utils.getDocument(message, baseUri, map, ctx, server.getEndpoint().getEndpointInfo()); Document doc2 = utils.getDocument(message, baseUri, map, ctx, server.getEndpoint().getEndpointInfo()); assertFalse(doc == doc2); } finally { server.stop(); } } }
def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation); new WSDLGetUtils().updateWSDLPublishedEndpointAddress(def, endpointInfo);
public static Map<String, String> getSchemaLocations(Server server) { Message message = PhaseInterceptorChain.getCurrentMessage(); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); return utils.getSchemaLocations(message, base, ctxUri, info); }
public Set<String> getWSDLIds(Message message, String base, String ctxUri, EndpointInfo endpointInfo) { Map<String, String> params = new HashMap<>(); params.put("wsdl", ""); getDocument(message, base, params, ctxUri, endpointInfo); Map<String, Definition> mp = CastUtils.cast((Map<?, ?>)endpointInfo.getService() .getProperty(WSDLS_KEY)); return mp.keySet(); } public Map<String, String> getSchemaLocations(Message message,
utils = new WSDLGetUtils(); message.put(WSDLGetUtils.class, utils);
for (Element el : elementList) { String sl = el.getAttribute("schemaLocation"); sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI()); if (sl != null) { el.setAttribute("schemaLocation", sl); for (Element el : elementList) { String sl = el.getAttribute("schemaLocation"); sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI()); if (sl != null) { el.setAttribute("schemaLocation", sl); for (Element el : elementList) { String sl = el.getAttribute("schemaLocation"); sl = mapUri(bus, base, smp, sl, xsdWsdlPar, doc.getDocumentURI()); if (sl != null) { el.setAttribute("schemaLocation", sl); String sl = el.getAttribute("location"); try { sl = getLocationURI(sl, xsdWsdlPar); } catch (URISyntaxException e) { String basePath = (String) message.get("http.base.path"); for (Element el : portList) { rewriteAddressProtocolHostPort(base, el, basePath, "http://schemas.xmlsoap.org/wsdl/soap/"); rewriteAddressProtocolHostPort(base, el, basePath, "http://schemas.xmlsoap.org/wsdl/soap12/"); if (name.equals(message.getExchange().getEndpoint().getEndpointInfo()
String resolvedSchemaLocation = resolveWithCatalogs(catalogs, start, base); } catch (MalformedURLException e) { try { start = getLocationURI(start, docBase); decodedStart = URLDecoder.decode(start, "utf-8"); } catch (Exception e1) { done.put(imp.getDefinition().getDocumentBaseURI(), imp.getDefinition()); updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, start, null); done.put(imp.getDefinition().getDocumentBaseURI(), imp.getDefinition()); updateDefinition(bus, imp.getDefinition(), done, doneSchemas, base, start, resolvedSchemaLocation); : CastUtils.cast(types.getExtensibilityElements(), ExtensibilityElement.class)) { if (el instanceof Schema) { updateSchemaImports(bus, (Schema)el, docBase, doneSchemas, base, parentResolvedLocation);