Example usage for javax.xml.ws Endpoint publish

List of usage examples for javax.xml.ws Endpoint publish

Introduction

In this page you can find the example usage for javax.xml.ws Endpoint publish.

Prototype

public static Endpoint publish(String address, Object implementor) 

Source Link

Document

Creates and publishes an endpoint for the specified implementor object at the given address.

Usage

From source file:org.graphwalker.GUI.App.java

private void runSoap() {
    if (endpoint != null) {
        endpoint = null;/*  w  w w  .j a v a  2 s . co m*/
    }
    setWaitCursor();

    if (executeMBT != null) {
        executeMBT.cancel(true);
    }

    String wsURL = "http://0.0.0.0:" + Util.readWSPort() + "/mbt-services";
    try {
        mbt = Util.loadMbtAsWSFromXml(Util.getFile(xmlFile.getAbsolutePath()));
        mbt.setUseGUI();
        soapService = new SoapServices(mbt);
        soapService.xmlFile = xmlFile.getAbsolutePath();
    } catch (Exception e) {
        logger.error("Failed to start the SOAP service. " + e.getMessage());
        JOptionPane.showMessageDialog(App.getInstance(), "Failed to start the SOAP service. " + e.getMessage());
        soapButton.setSelected(false);
        status.setStopped();
        reset();
        return;
    }
    endpoint = Endpoint.publish(wsURL, soapService);

    try {
        String msg = "Now running as a SOAP server. For the WSDL file, see: "
                + wsURL.replace("0.0.0.0", InetAddress.getLocalHost().getHostName()) + "?WSDL";
        logger.info(msg);
        if (!Util.readSoapGuiStartupState()) {
            JOptionPane.showMessageDialog(App.getInstance(), msg);
        }
        status.unsetState(Status.stopped);
        status.unsetState(Status.paused);
        status.setState(Status.executingSoapTest);
        statusBar.setMessage(msg);
    } catch (UnknownHostException e) {
        logger.error("Failed to start the SOAP service. " + e.getMessage());
        JOptionPane.showMessageDialog(App.getInstance(), "Failed to start the SOAP service. " + e.getMessage());
        soapButton.setSelected(false);
        status.setStopped();
        reset();
    } finally {
        setButtons();
        setDefaultCursor();
        updateLayout();
    }
}

From source file:org.kuali.rice.test.remote.RemoteTestHarness.java

@SuppressWarnings("unchecked")
/**/*w  w  w  . ja  v a 2s  .co m*/
 * Creates a published endpoint from the passed in serviceImplementation and also returns a proxy implementation
 * of the passed in interface for clients to use to hit the created endpoint.
 */
public <T> T publishEndpointAndReturnProxy(Class<T> jaxWsAnnotatedInterface, T serviceImplementation) {
    if (jaxWsAnnotatedInterface.isInterface() && jaxWsAnnotatedInterface.getAnnotation(WebService.class) != null
            && jaxWsAnnotatedInterface.isInstance(serviceImplementation)) {

        String endpointUrl = getAvailableEndpointUrl();
        LOG.info("Publishing service to: " + endpointUrl);
        endpoint = Endpoint.publish(endpointUrl, serviceImplementation);

        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(jaxWsAnnotatedInterface);
        factory.setAddress(endpointUrl);

        T serviceProxy = (T) factory.create();

        /* Add the ImmutableCollectionsInInterceptor to mimic interceptors added in the KSB */
        Client cxfClient = ClientProxy.getClient(serviceProxy);
        cxfClient.getInInterceptors().add(new ImmutableCollectionsInInterceptor());

        return serviceProxy;
    } else {
        throw new IllegalArgumentException("Passed in interface class type must be annotated with @WebService "
                + "and object reference must be an implementing class of that interface.");

    }
}

From source file:org.meerkat.MeerkatMonitor.java

/**
 * main/*from   www .  j a v a2s  .  c  o m*/
 * 
 * @param args
 */
public static void main(String[] args) {
    int numberStepsToProgress = 14;
    double percentIncrease = 100 / numberStepsToProgress;
    double currProgress = 0;

    PropertiesLoader pL = new PropertiesLoader(propertiesFile);
    pL.validateProperties(); // validate present properties
    properties = pL.getPropetiesFromFile();

    try {
        splashScreen = new SplashScreen(version);
    } catch (Exception e) {
        log.warn("No Graphical interface available: " + e.getMessage());
    }
    // Show splash screen if available
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            try {
                splashScreen.showScreen();
                isSplashSupported = true;
            } catch (Exception e) {
                log.info("Desktop environment not available. [Running in console mode]");
            }
        }
    });

    if (isSplashSupported) {
        splashScreen.setProgress("Meekat-Monitor v." + version + " starting...",
                (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Meekat-Monitor v." + version + " starting...");

    try {
        Thread.sleep(1000);
    } catch (InterruptedException e1) {
        log.error("Faile to sleep thread! " + e1.getMessage());
    }

    // Try to ping meerkat-monitor.org
    if (Boolean.parseBoolean(properties.getProperty("meerkat.mma.usage.stats"))) {
        // Auto-configure java proxy based on system settings
        ProxySystemSettings proxySettings = new ProxySystemSettings();
        proxySettings.setProxyAutoDetectSystemSettings();

        MMA_PostInfo pInfo = new MMA_PostInfo();
        try {
            pInfo.postInfo();
            log.info("Anonymous usage statistics enabled.");
        } catch (Exception e2) {
            log.warn("Unable to ping: meerkat-monitor.org");
        }
    } else {
        log.info("Send anonymous usage statistics is: Disabled.");
    }

    // Setup general log settings
    if (isSplashSupported) {
        splashScreen.setProgress("Loading settings...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Updating log setting...");
    LogSettings ls = new LogSettings();
    ls.setupLogGeneralOptions();
    // Set up apache cxf log through log4j
    java.util.logging.Logger jlog = java.util.logging.Logger.getLogger("org.apache.cxf");
    jlog.setLevel(Level.WARNING);
    // Set httpclient log to error only
    System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
    System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "error");
    System.setProperty("derby.locks.deadlockTrace", "true");

    // Load SQL Drivers
    if (isSplashSupported) {
        splashScreen.setProgress("Loading JDBC Drivers and DB...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Loading JDBC Drivers...");
    SQLDriverLoader sqlDL = new SQLDriverLoader();
    sqlDL.loadDrivers();

    // Setup embedded Database
    if (isSplashSupported) {
        splashScreen.setProgress("Setting up embedded database...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Setting up embedded database...");
    EmbeddedDB ebd = new EmbeddedDB();
    // Load the driver first time
    ebd.loadDriver();
    ebd.initializeDB();

    /**
    if(isSplashSupported){
       splashScreen.setProgress("Executing database maintenance...", (int)Math.round(currProgress));
       currProgress += percentIncrease;
    }
    ebd.executeDBMaintenance();
     */

    // Prepare applications settings
    if (isSplashSupported) {
        splashScreen.setProgress("Loading application settings...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }

    log.info("Loading application settings...");
    // Prepare temporary working directory
    if (isSplashSupported) {
        splashScreen.setProgress("Creating applications...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Setting temporary dir: ");
    mgo = new MeerkatGeneralOperations(configFile, version);
    String tempWorkingDir = mgo.getTmpWorkingDir();

    // Loading / Creating applications
    WebAppCollection webAppsCollection = mgo.loadWebAppsXML();

    // Create the password manager MasterKeyManager
    mkm = new MasterKeyManager(propertiesFile, webAppsCollection);

    // Generate applications groups
    if (isSplashSupported) {
        splashScreen.setProgress("Creating groups...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Creating applications groups...");
    AppGroupCollection appGroupCollection = new AppGroupCollection();
    appGroupCollection.populateGroups(webAppsCollection);
    appGroupCollection.printLogGroupMembers();
    webAppsCollection.setGroupCollection(appGroupCollection); // Set group to app collection

    // Setup email settings
    if (isSplashSupported) {
        splashScreen.setProgress("Setting up email settings...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Setting up email settings...");
    MailManager mailManager = new MailManager(propertiesFile);
    boolean sendEmails = Boolean.parseBoolean(properties.getProperty("meerkat.email.send.emails"));
    boolean testEmailSending = Boolean.parseBoolean(properties.getProperty("meerkat.email.sending.test"));
    if (sendEmails && testEmailSending) {
        mailManager.sendTestEmail();
    }

    // Create the RSS Feed
    if (isSplashSupported) {
        splashScreen.setProgress("Setting up RSS...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Creating RSS service...");
    rssFeed = new RSS("Meerkat Monitor", "Meerkat Monitor RSS Alerts", "",
            new File(mgo.getTmpWorkingDir()).getAbsolutePath());
    rssFeed.refreshRSSFeed();
    webserverPort = Integer.parseInt(properties.getProperty("meerkat.webserver.port"));
    rssFeed.setServerPort(webserverPort);

    // Extract needed resources
    if (isSplashSupported) {
        splashScreen.setProgress("Extracting resources...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Extracting resources...");
    mgo.extractWebResourcesResources();

    // Link DB to app
    webAppsCollection.setDB(ebd);

    // Setup web server
    if (isSplashSupported) {
        splashScreen.setProgress("Setting up embedded server...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    log.info("Setting up embedded server...");
    String wsdlEndpoint = "http://" + hostname + ":" + (webserverPort + 1) + webServiceRoot;
    String wsdlUrl = wsdlEndpoint + "?wsdl";
    webServicesWSDL = wsdlUrl;

    httpWebServer = new HttpServer(webserverPort, version, wsdlUrl, tempWorkingDir);
    httpWebServer.setDataSources(webAppsCollection, appGroupCollection);
    // publish web services
    Endpoint.publish(wsdlEndpoint, new MeerkatWebService(mkm, webAppsCollection, httpWebServer));
    // set the httpServer to webapp collection
    webAppsCollection.setHttpServer(httpWebServer);

    // Open Dashboard in default browser if available
    if (isSplashSupported) {
        splashScreen.setProgress("Finalizing...", (int) Math.round(currProgress));
        currProgress += percentIncrease;
    }
    try {
        java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
        java.net.URI uri = new java.net.URI("http://" + hostname + ":" + webserverPort);
        desktop.browse(uri);
    } catch (Exception e) {
        log.info("[Console mode] Please open URL manually: http://" + hostname + ":" + webserverPort + ")");
    }

    // Start monitor
    log.info("Setting up monitor...");
    Monitor monitor = new Monitor(ebd, webAppsCollection, appGroupCollection, httpWebServer, rssFeed,
            propertiesFile);
    if (isSplashSupported) {
        splashScreen.setProgress("Done!", (int) Math.round(currProgress));
        currProgress += percentIncrease;
        splashScreen.close();
    }
    monitor.startMonitor();

}

From source file:org.nebulaframework.discovery.ws.colombus.ColombusServer.java

/**
 * Creates the Service EndPoint for Discovery Service.
 *///from   w  w w  .  j  a v a 2s  .c om
private static void startDiscoveryService() {

    ColombusDiscoveryImpl discoveryImpl = new ColombusDiscoveryImpl();
    String address = "http://localhost:" + port + "/Colombus/Discovery";
    Endpoint.publish(address, discoveryImpl);

    log.debug("[Colombus Server] Published EndPoint : " + address);
}

From source file:org.nebulaframework.discovery.ws.colombus.ColombusServer.java

/**
 * Creates Service EndPoint for Management Service
 */// www  .  j  a  v  a2 s.  co  m
private static void startManagerService() {

    ColombusManagerImpl managerImpl = new ColombusManagerImpl();
    String address = "http://localhost:" + port + "/Colombus/Manager";
    Endpoint.publish(address, managerImpl);

    log.debug("[Colombus Server] Published EndPoint : " + address);
}

From source file:org.openehealth.tutorial.imagebin.ImageBinServer.java

public void start() {
    File directory = new File("target/store");
    directory.mkdir();/*from  w  w  w  . j  a va 2s.c om*/

    log.debug("Starting ImageBin Server");

    // Publish the service
    Object imageBin = new ImageBinImpl(directory.getAbsolutePath());
    String address = "http://localhost:8413/ImageBin/ImageBinPort";
    imageBinEndpoint = Endpoint.publish(address, imageBin);

    // Enable MTOM attachments
    SOAPBinding binding = (SOAPBinding) imageBinEndpoint.getBinding();
    binding.setMTOMEnabled(true);

    log.debug("ImageBin ready");
}

From source file:org.pentaho.platform.repository2.unified.webservices.jaxws.DefaultUnifiedRepositoryJaxwsWebServiceIT.java

@Before
public void setUp() throws Exception {
    super.setUp();

    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);

    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);

    String address = "http://localhost:9000/repo";
    Endpoint.publish(address, new DefaultUnifiedRepositoryJaxwsWebService(repo));

    Service service = Service.create(new URL("http://localhost:9000/repo?wsdl"),
            new QName("http://www.pentaho.org/ws/1.0", "unifiedRepository"));

    IUnifiedRepositoryJaxwsWebService repoWebService = service.getPort(IUnifiedRepositoryJaxwsWebService.class);

    // accept cookies to maintain session on server
    ((BindingProvider) repoWebService).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    // support streaming binary data
    ((BindingProvider) repoWebService).getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE,
            8192);/*from  w  ww  . j  a  v  a 2s  .  com*/
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) repoWebService).getBinding();
    binding.setMTOMEnabled(true);

    repo = new UnifiedRepositoryToWebServiceAdapter(repoWebService);

}

From source file:ru.codeinside.gws.core.sproto.R120315_Metro_Test.java

@Test
public void testRequestParsing() throws IOException {
    final URL addr = new URL("http://127.0.0.1:7771/");
    final AtomicReference<ServerRequest> request = new AtomicReference<ServerRequest>();
    Endpoint endpoint = Endpoint.publish("http://127.0.0.1:7771/", new Router(new Invoker() {
        @Override//from   www . j  av  a2  s .  com
        public SOAPMessage invoke(SOAPMessage in, WebServiceContext ctx) {
            CryptoProvider cryptoProvider = mock(CryptoProvider.class);
            R120315 r120315 = new R120315(cryptoProvider);
            request.set(r120315.processRequest(in, mvvPort.service, mvvPort.portDef));

            ServerResponse response = new ServerResponse();
            response.action = new QName("http://mvv.oep.com/", "putData");
            Packet p = new Packet();
            response.packet = p;
            p.exchangeType = "Test";
            p.serviceCode = "111111111111";
            p.requestIdRef = "111111111111";
            p.originRequestIdRef = "111111111111";
            p.caseNumber = "111111111111";
            p.typeCode = Packet.Type.SERVICE;
            p.status = Packet.Status.PROCESS;
            p.recipient = p.sender = new InfoSystem("PNZR01581", "111111111");
            p.date = new Date();

            return r120315.processResponse(null, response, mvvPort.service, mvvPort.portDef, null);
        }
    }));
    try {
        assertTrue(endpoint.isPublished());
        HttpURLConnection con = (HttpURLConnection) addr.openConnection();
        con.setRequestProperty("Content-type", "text/xml; charset=utf-8");
        con.setDoOutput(true);
        con.setDoInput(true);
        IOUtils.copy(R.getRequiredResourceStream("mvvact/putData/request.xml"), con.getOutputStream());
        String result = IOUtils.toString(con.getInputStream(), "UTF8");
        assertNotNull(result);

        ServerRequest req = request.get();

        assertNull(req.routerPacket);
        assertEquals(new QName("http://mvv.oep.com/", "putData"), req.action);
        assertEquals("UniversalMVV", req.packet.serviceName);
        assertEquals(Packet.Type.SERVICE, req.packet.typeCode);
        assertEquals(Packet.Status.REQUEST, req.packet.status);
        assertEquals("Test", req.packet.exchangeType);
        assertEquals("111111111111", req.packet.requestIdRef);
        assertEquals("111111111111", req.packet.originRequestIdRef);
        assertEquals("111111111111", req.packet.serviceCode);
        assertEquals("111111111111", req.packet.caseNumber);
        assertNull(req.attachmens);
        assertNull(req.docRequestCode);
    } finally {
        endpoint.stop();
    }
}

From source file:ru.codeinside.gws.core.sproto.R120315_Metro_Test.java

@Test
public void testValidationIn() throws IOException {
    String portAddr = "http://127.0.0.1:7772/";
    Endpoint endpoint = Endpoint.publish(portAddr, new Router(null));
    try {//from   w  w w .  j a v a  2 s  . co m
        assertTrue(endpoint.isPublished());
        HttpURLConnection con = (HttpURLConnection) new URL(portAddr).openConnection();
        con.setRequestProperty("Content-type", "text/xml; charset=utf-8");
        con.setDoOutput(true);
        con.setDoInput(true);
        IOUtils.copy(R.getRequiredResourceStream("fss-request-1.xml"), con.getOutputStream());
        assertEquals(500, con.getResponseCode());
        String error = IOUtils.toString(con.getErrorStream(), "UTF8");
        assertTrue(error.contains("Cannot find the declaration of element 'ws:request'"));
    } finally {
        endpoint.stop();
    }
}

From source file:ru.codeinside.gws.core.sproto.R120315_Metro_Test.java

@Test
public void testValidationOut() throws IOException {
    final AtomicReference<ServerRequest> request = new AtomicReference<ServerRequest>();
    String portAddr = "http://127.0.0.1:7773/";
    Endpoint endpoint = Endpoint.publish(portAddr, new Router(new Invoker() {
        @Override//from w  w w .  j a  v a2 s . c o m
        public SOAPMessage invoke(SOAPMessage in, WebServiceContext ctx) {
            CryptoProvider cryptoProvider = mock(CryptoProvider.class);
            R120315 r120315 = new R120315(cryptoProvider);
            request.set(r120315.processRequest(in, mvvPort.service, mvvPort.portDef));
            try {
                return R.getSoapResource("fss-response-2.xml");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }));
    try {
        assertTrue(endpoint.isPublished());
        HttpURLConnection con = (HttpURLConnection) new URL(portAddr).openConnection();
        con.setRequestProperty("Content-type", "text/xml; charset=utf-8");
        con.setDoOutput(true);
        con.setDoInput(true);
        IOUtils.copy(R.getRequiredResourceStream("mvvact/updateStatus/UpdateStatus_request.xml"),
                con.getOutputStream());
        assertEquals(500, con.getResponseCode());
        String error = IOUtils.toString(con.getErrorStream(), "UTF8");
        assertTrue(error.contains("Cannot find the declaration of element 'ns3:requestResponse'"));

        ServerRequest req = request.get();
        assertNull(req.routerPacket);
        assertEquals(new QName("http://mvv.oep.com/", "updateStatus"), req.action);
        assertNull(req.packet.serviceName);
        assertEquals(Packet.Type.SERVICE, req.packet.typeCode);
        assertEquals(Packet.Status.REQUEST, req.packet.status);
        assertEquals("Test", req.packet.exchangeType);
        assertEquals("11111111111", req.packet.requestIdRef);
        assertEquals("111111111111", req.packet.originRequestIdRef);
        assertEquals("1111111111", req.packet.serviceCode);
        assertEquals("1111111111111", req.packet.caseNumber);
        assertNull(req.attachmens);
        assertNull(req.docRequestCode);

    } finally {
        endpoint.stop();
    }
}