use of javax.xml.ws.Endpoint in project spring-framework by spring-projects.
the class AbstractJaxWsServiceExporter method publishEndpoints.
/**
* Publish all {@link javax.jws.WebService} annotated beans in the
* containing BeanFactory.
* @see #publishEndpoint
*/
public void publishEndpoints() {
Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
if (this.beanFactory instanceof ConfigurableBeanFactory) {
beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
}
for (String beanName : beanNames) {
try {
Class<?> type = this.beanFactory.getType(beanName);
if (type != null && !type.isInterface()) {
WebService wsAnnotation = type.getAnnotation(WebService.class);
WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
if (wsAnnotation != null || wsProviderAnnotation != null) {
Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
if (this.endpointProperties != null) {
endpoint.setProperties(this.endpointProperties);
}
if (this.executor != null) {
endpoint.setExecutor(this.executor);
}
if (wsAnnotation != null) {
publishEndpoint(endpoint, wsAnnotation);
} else {
publishEndpoint(endpoint, wsProviderAnnotation);
}
this.publishedEndpoints.add(endpoint);
}
}
} catch (CannotLoadBeanClassException ex) {
// ignore beans where the class is not resolvable
}
}
}
use of javax.xml.ws.Endpoint in project jdk8u_jdk by JetBrains.
the class TestWsImport method main.
public static void main(String[] args) throws IOException {
String javaHome = System.getProperty("java.home");
if (javaHome.endsWith("jre")) {
javaHome = new File(javaHome).getParent();
}
String wsimport = javaHome + File.separator + "bin" + File.separator + "wsimport";
if (System.getProperty("os.name").startsWith("Windows")) {
wsimport = wsimport.concat(".exe");
}
Endpoint endpoint = Endpoint.create(new TestService());
HttpServer httpServer = null;
try {
// Manually create HttpServer here using ephemeral address for port
// so as to not end up with attempt to bind to an in-use port
httpServer = HttpServer.create(new InetSocketAddress(0), 0);
HttpContext httpContext = httpServer.createContext("/hello");
int port = httpServer.getAddress().getPort();
System.out.println("port = " + port);
httpServer.start();
endpoint.publish(httpContext);
String address = "http://localhost:" + port + "/hello";
Service service = Service.create(new URL(address + "?wsdl"), new QName("http://test/jaxws/sample/", "TestService"));
String[] wsargs = { wsimport, "-p", "wstest", "-J-Djavax.xml.accessExternalSchema=all", "-J-Dcom.sun.tools.internal.ws.Invoker.noSystemProxies=true", address + "?wsdl", "-clientjar", "wsjar.jar" };
ProcessBuilder pb = new ProcessBuilder(wsargs);
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s = r.readLine();
while (s != null) {
System.out.println(s.trim());
s = r.readLine();
}
p.waitFor();
p.destroy();
try (JarFile jarFile = new JarFile("wsjar.jar")) {
for (Enumeration em = jarFile.entries(); em.hasMoreElements(); ) {
String fileName = em.nextElement().toString();
if (fileName.contains("\\")) {
throw new RuntimeException("\"\\\" character detected in jar file: " + fileName);
}
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
} finally {
endpoint.stop();
if (httpServer != null) {
httpServer.stop(0);
}
Path p = Paths.get("wsjar.jar");
Files.deleteIfExists(p);
p = Paths.get("wstest");
if (Files.exists(p)) {
try {
Files.walkFileTree(p, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
if (exc == null) {
Files.delete(dir);
return CONTINUE;
} else {
throw exc;
}
}
});
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
}
use of javax.xml.ws.Endpoint in project jdk8u_jdk by JetBrains.
the class WSTest method main.
public static void main(String[] args) throws Exception {
// find a free port
ServerSocket ss = new ServerSocket(0);
int port = ss.getLocalPort();
ss.close();
Endpoint endPoint1 = null;
Endpoint endPoint2 = null;
try {
endPoint1 = Endpoint.publish("http://0.0.0.0:" + port + "/method1", new Method1());
endPoint2 = Endpoint.publish("http://0.0.0.0:" + port + "/method2", new Method2());
System.out.println("Sleep 3 secs...");
Thread.sleep(3000);
} finally {
stop(endPoint2);
stop(endPoint1);
}
}
use of javax.xml.ws.Endpoint in project webservices-axiom by apache.
the class MTOMSample method test.
// END SNIPPET: retrieveContent
public void test() throws Exception {
int port = PortAllocator.allocatePort();
Endpoint endpoint = Endpoint.publish("http://localhost:" + port + "/mtom", new MTOMService());
retrieveContent(new URL("http://localhost:" + port + "/mtom"), "G87ZX20047", System.out);
endpoint.stop();
}
Aggregations