use of org.apache.cxf.frontend.WSDLGetUtils in project cxf by apache.
the class MEXUtils method getSchemas.
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<Element>();
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;
}
use of org.apache.cxf.frontend.WSDLGetUtils in project cxf by apache.
the class WsdlGetUtilsTest method testNewDocumentIsCreatedForEachWsdlRequest.
@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();
}
}
use of org.apache.cxf.frontend.WSDLGetUtils in project cxf by apache.
the class EndpointImpl method doPublish.
/**
* Performs the publication action by setting up a {@link Server}
* instance based on this endpoint's configuration.
*
* @param addr the optional endpoint address.
*
* @throws IllegalStateException if the endpoint cannot be published/republished
* @throws SecurityException if permission checking is enabled and policy forbids publishing
* @throws WebServiceException if there is an error publishing the endpoint
*
* @see #checkPublishPermission()
* @see #checkPublishable()
* @see #getServer(String)
*/
protected void doPublish(String addr) {
checkPublishPermission();
checkPublishable();
ServerImpl serv = null;
ClassLoaderHolder loader = null;
try {
if (bus != null) {
ClassLoader newLoader = bus.getExtension(ClassLoader.class);
if (newLoader != null) {
loader = ClassLoaderUtils.setThreadContextClassloader(newLoader);
}
}
serv = getServer(addr);
if (addr != null) {
EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
if (endpointInfo.getAddress() == null || !endpointInfo.getAddress().contains(addr)) {
endpointInfo.setAddress(addr);
}
if (publishedEndpointUrl != null) {
endpointInfo.setProperty(WSDLGetUtils.PUBLISHED_ENDPOINT_URL, publishedEndpointUrl);
}
if (publishedEndpointUrl != null && wsdlLocation != null) {
// early update the publishedEndpointUrl so that endpoints in the same app sharing the same wsdl
// do not require all of them to be queried for wsdl before the wsdl is finally fully updated
Definition def = endpointInfo.getService().getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class);
if (def == null) {
def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation);
}
new WSDLGetUtils().updateWSDLPublishedEndpointAddress(def, endpointInfo);
}
if (null != properties) {
for (Entry<String, Object> entry : properties.entrySet()) {
endpointInfo.setProperty(entry.getKey(), entry.getValue());
}
}
this.address = endpointInfo.getAddress();
}
serv.start();
publishable = false;
} catch (Exception ex) {
try {
stop();
} catch (Exception e) {
// Nothing we can do.
}
throw new WebServiceException(ex);
} finally {
if (loader != null) {
loader.reset();
}
}
}
use of org.apache.cxf.frontend.WSDLGetUtils in project cxf by apache.
the class MEXUtils method getWSDLs.
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<Element>();
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;
}
use of org.apache.cxf.frontend.WSDLGetUtils in project cxf by apache.
the class MEXUtils method getSchemaLocations.
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);
}
Aggregations