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.apache.juddi.v3.client.subscription.SubscriptionCallbackListener.java

/**
 * Starts a embedded Jetty web server (comes with the JDK) using the
 * Endpoint API./*from   w w w.  jav a 2 s. c o  m*/
 *
 * @param client
 * @param cfg_node_name
 * @param endpoint this is the url that a UDDI server would use to
 * connect to the client's subscription listener service Recommend
 * specifying a port that is firewall friendly
 * @param keydomain
         
 * @param autoregister
 * @param behavior
 * @param serviceKey
 * @return null, if and only if callbackBusinessService was null,
 * otherwise the modified callbackBusinessService is returned. Clients
 * can then use it to continue the registration process.
 * @throws ServiceAlreadyStartedException
 * @throws SecurityException
 * @throws ConfigurationException
 * @throws TransportException
 * @throws DispositionReportFaultMessage
 * @throws java.rmi.UnexpectedException
 * @throws org.apache.juddi.v3.client.subscription.RegistrationAbortedException
 * @throws java.net.MalformedURLException
 * @throws org.apache.juddi.v3.client.subscription.UnableToSignException
 * @see Endpoint
 */
public static synchronized BindingTemplate start(UDDIClient client, String cfg_node_name, String endpoint,
        String keydomain, boolean autoregister, String serviceKey, SignatureBehavior behavior)
        throws ServiceAlreadyStartedException, SecurityException, ConfigurationException, TransportException,
        DispositionReportFaultMessage, RemoteException, UnexpectedException, RegistrationAbortedException,
        UnableToSignException, MalformedURLException {

    if (instance == null) {
        instance = new SubscriptionCallbackListener();
    }

    if (ep != null && ep.isPublished()) {
        throw new ServiceAlreadyStartedException();
    }

    URL url = null;
    try {
        url = new URL(endpoint);
    } catch (Exception ex) {
        log.warn("Callback endpoint couldn't be parsed, generating a random one: " + ex.getMessage());
        url = new URL(
                "http://" + GetHostname() + ":" + GetRandomPort(4000) + "/" + UUID.randomUUID().toString());
    }
    endpoint = url.toString();
    //if (endpoint == null || endpoint.equals("")) {
    //    endpoint = "http://" + GetHostname() + ":" + GetRandomPort(url.getPort()) + "/" + UUID.randomUUID().toString();

    int attempts = 5;
    if (ep == null) {
        while ((ep == null || !ep.isPublished()) && attempts > 0) {
            try {
                ep = Endpoint.publish(endpoint, instance);
                callback = endpoint;
            } catch (Exception be) {
                log.info("trouble starting callback at " + endpoint + ", trying again with a random port: "
                        + be.getMessage());
                log.debug(be);
                attempts--;
                //if (be instanceof java.net.BindException) {
                url = new URL(
                        "http://" + url.getHost() + ":" + GetRandomPort(url.getPort()) + "/" + url.getPath());
                endpoint = url.toString();

            }
        }
    }
    if (ep == null || !ep.isPublished()) {
        log.warn("Unable to start callback endpoint, aborting");
        throw new SecurityException("unable to start endpoint, view previous errors for reason");
    }

    log.info("Endpoint started at " + callback);

    BindingTemplate bt = new BindingTemplate();
    bt.setAccessPoint(new AccessPoint());
    bt.getAccessPoint().setValue(callback);
    bt.getAccessPoint().setUseType("endPoint");
    TModelInstanceInfo instanceInfo = new TModelInstanceInfo();
    instanceInfo.setTModelKey("uddi:uddi.org:transport:http");
    bt.setTModelInstanceDetails(new TModelInstanceDetails());
    bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo);
    bt.setServiceKey(serviceKey);
    if (keydomain.endsWith(":")) {
        bt.setBindingKey(keydomain + GetHostname() + "_subscription_callback");
    } else {
        bt.setBindingKey(keydomain + ":" + GetHostname() + "_subscription_callback");
    }

    if (autoregister) {
        bt = registerBinding(client, cfg_node_name, bt, behavior);
    }

    return bt;

}

From source file:org.apache.juddi.v3.tck.UDDI_090_HttpExternalTest.java

@BeforeClass
public static void startup() throws Exception {
    if (!TckPublisher.isEnabled())
        return;/*from  w  w  w.  j  av a 2 s.c o m*/
    startManager();
    hostname = TckPublisher.getProperties().getProperty("bindaddress");
    if (hostname == null) {
        hostname = InetAddress.getLocalHost().getHostName();
    }
    port = 9600;
    //bring up the TCK SubscriptionListener
    String httpEndpoint = "http://" + hostname + ":" + port + "/tcksubscriptionlistener";
    System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
    endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
    int count = 0;
    while (!endPoint.isPublished()) {
        port = 9600 + new Random().nextInt(99);
        httpEndpoint = "http://" + hostname + ":" + port + "/tcksubscriptionlistener";
        System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
        endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
        count++;
        if (count > 10) {
            Assert.fail("unable to bring up endpoint");
        }
    }

}

From source file:org.apache.juddi.v3.tck.UDDI_090_HttpMavenIntegrationTest.java

@BeforeClass
public static void startup() throws Exception {

    if (!TckPublisher.isEnabled()) {
        return;//ww w . j a  va  2 s  . c  om
    }
    startManager();
    hostname = "localhost";
    //bring up the TCK SubscriptionListener
    port = 9600;
    String httpEndpoint = "http://" + hostname + ":" + port + "/tcksubscriptionlistener";
    System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
    endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
    int count = 0;
    while (!endPoint.isPublished()) {
        port = 9600 + new Random().nextInt(99);
        httpEndpoint = "http://" + hostname + ":" + port + "/tcksubscriptionlistener";
        System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
        endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
        count++;
        if (count > 10) {
            Assert.fail("unable to bring up endpoint");
        }
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_090_SubscriptionListenerExternalTest.java

@BeforeClass
public static void startManager() throws ConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    try {/*  www .j  a v  a2s  . c  o m*/
        httpPort = 9600 + new Random().nextInt(99);

        hostname = TckPublisher.getProperties().getProperty("bindaddress");
        if (hostname == null) {
            hostname = InetAddress.getLocalHost().getHostName();
        }

        //bring up the TCK SubscriptionListener
        String httpEndpoint = "http://" + hostname + ":" + httpPort + "/tcksubscriptionlistener";
        System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
        endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());

        manager = new UDDIClient();
        manager.start();

        logger.debug("Getting auth tokens..");

        Transport transport = manager.getTransport("uddiv3");
        UDDISecurityPortType security = transport.getUDDISecurityService();
        authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),
                TckPublisher.getJoePassword());
        authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(),
                TckPublisher.getMaryPassword());

        UDDIPublicationPortType publication = transport.getUDDIPublishService();
        inquiryJoe = transport.getUDDIInquiryService();
        subscriptionJoe = transport.getUDDISubscriptionService();
        if (!TckPublisher.isUDDIAuthMode()) {
            TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(),
                    TckPublisher.getJoePassword());
            TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getJoePublisherId(),
                    TckPublisher.getJoePassword());
            TckSecurity.setCredentials((BindingProvider) subscriptionJoe, TckPublisher.getJoePublisherId(),
                    TckPublisher.getJoePassword());
        }

        tckTModelJoe = new TckTModel(publication, inquiryJoe);
        tckBusinessJoe = new TckBusiness(publication, inquiryJoe);
        tckBusinessServiceJoe = new TckBusinessService(publication, inquiryJoe);
        tckSubscriptionListenerJoe = new TckSubscriptionListener(subscriptionJoe, publication);

        transport = manager.getTransport("uddiv3");
        publication = transport.getUDDIPublishService();
        publicationMary = publication;
        inquiryMary = transport.getUDDIInquiryService();
        subscriptionMary = transport.getUDDISubscriptionService();
        if (!TckPublisher.isUDDIAuthMode()) {
            TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getMaryPublisherId(),
                    TckPublisher.getMaryPassword());
            TckSecurity.setCredentials((BindingProvider) inquiryMary, TckPublisher.getMaryPublisherId(),
                    TckPublisher.getMaryPassword());
            TckSecurity.setCredentials((BindingProvider) subscriptionMary, TckPublisher.getMaryPublisherId(),
                    TckPublisher.getMaryPassword());
        }

        tckTModelMary = new TckTModel(publication, inquiryMary);
        tckBusinessMary = new TckBusiness(publication, inquiryMary);
        tckBusinessServiceMary = new TckBusinessService(publication, inquiryMary);
        tckSubscriptionListenerMary = new TckSubscriptionListener(subscriptionMary, publication);

        email = TckPublisher.getProperties().getProperty("mail.pop3.to");

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("Could not obtain authInfo token.");
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_090_SubscriptionListenerIntegrationTest.java

@BeforeClass
public static void startManager() throws ConfigurationException {
    Assume.assumeTrue(TckPublisher.isEnabled());
    try {/*from   ww w  .j  a v  a2  s .  c  om*/
        smtpPort = 9700 + new Random().nextInt(99);
        httpPort = 9600 + new Random().nextInt(99);
        Properties properties = new Properties();
        properties.setProperty("juddi.mail.smtp.host", "localhost");
        properties.setProperty("juddi.mail.smtp.port", String.valueOf(smtpPort));
        properties.setProperty("juddi.mail.smtp.from", "jUDDI@example.org");
        String version = Release.getRegistryVersion().replaceAll(".SNAPSHOT", "-SNAPSHOT");
        String curDir = System.getProperty("user.dir");
        if (!curDir.endsWith("uddi-tck")) {
            curDir += "/uddi-tck";
        }
        String path = curDir + "/target/juddi-tomcat-" + version + "/temp/";
        System.out.println("Saving jUDDI email properties to " + path);
        File tmpDir = new File(path);
        File tmpFile = new File(tmpDir + "/juddi-mail.properties");
        if (!tmpFile.createNewFile()) {
            tmpFile.delete();
            tmpFile.createNewFile();
        }
        properties.store(new FileOutputStream(tmpFile), "tmp email settings");

        hostname = InetAddress.getLocalHost().getHostName();
        //bring up the TCK SubscriptionListener
        String httpEndpoint = "http://" + hostname + ":" + httpPort + "/tcksubscriptionlistener";
        System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
        endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
        int count = 0;
        while (!endPoint.isPublished()) {
            httpPort = 9600 + new Random().nextInt(99);
            httpEndpoint = "http://" + hostname + ":" + httpPort + "/tcksubscriptionlistener";
            System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
            endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
            count++;
            if (count > 10) {
                Assert.fail("unable to bring up endpoint");
            }
        }

        manager = new UDDIClient();
        manager.start();

        logger.debug("Getting auth tokens..");

        Transport transport = manager.getTransport("uddiv3");
        UDDISecurityPortType security = transport.getUDDISecurityService();
        authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),
                TckPublisher.getJoePassword());
        authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(),
                TckPublisher.getMaryPassword());
        //Assert.assertNotNull(authInfoJoe);

        publicationJoe = transport.getUDDIPublishService();
        inquiryJoe = transport.getUDDIInquiryService();
        subscriptionJoe = transport.getUDDISubscriptionService();
        if (!TckPublisher.isUDDIAuthMode()) {
            TckSecurity.setCredentials((BindingProvider) publicationJoe, TckPublisher.getJoePublisherId(),
                    TckPublisher.getJoePassword());
            TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getJoePublisherId(),
                    TckPublisher.getJoePassword());
            TckSecurity.setCredentials((BindingProvider) subscriptionJoe, TckPublisher.getJoePublisherId(),
                    TckPublisher.getJoePassword());
        }

        tckTModelJoe = new TckTModel(publicationJoe, inquiryJoe);
        tckBusinessJoe = new TckBusiness(publicationJoe, inquiryJoe);
        tckBusinessServiceJoe = new TckBusinessService(publicationJoe, inquiryJoe);
        tckSubscriptionListenerJoe = new TckSubscriptionListener(subscriptionJoe, publicationJoe);

        transport = manager.getTransport("uddiv3");
        publicationMary = transport.getUDDIPublishService();
        inquiryMary = transport.getUDDIInquiryService();
        subscriptionMary = transport.getUDDISubscriptionService();
        if (!TckPublisher.isUDDIAuthMode()) {
            TckSecurity.setCredentials((BindingProvider) publicationMary, TckPublisher.getMaryPublisherId(),
                    TckPublisher.getMaryPassword());
            TckSecurity.setCredentials((BindingProvider) inquiryMary, TckPublisher.getMaryPublisherId(),
                    TckPublisher.getMaryPassword());
            TckSecurity.setCredentials((BindingProvider) subscriptionMary, TckPublisher.getMaryPublisherId(),
                    TckPublisher.getMaryPassword());
        }

        tckTModelMary = new TckTModel(publicationMary, inquiryMary);
        tckTModelMary.saveMaryPublisherTmodel(authInfoMary);

        tckBusinessMary = new TckBusiness(publicationMary, inquiryMary);
        tckBusinessServiceMary = new TckBusinessService(publicationMary, inquiryMary);
        tckSubscriptionListenerMary = new TckSubscriptionListener(subscriptionMary, publicationMary);

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        Assert.fail("Could not obtain authInfo token.");
    }
}

From source file:org.apache.juddi.v3.tck.UDDI_141_JIRAIntegrationTest.java

/**
 * testing upper case subscription callbacks
 *
 * @throws Exception//  ww w. j  ava  2s .  c  o m
 */
@Test
public void JIRA_597() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JIRA_597");

    int port = 7000;
    String hostname = TckPublisher.getProperties().getProperty("bindaddress");
    if (hostname == null) {
        hostname = InetAddress.getLocalHost().getHostName();
    }

    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    UDDISubscriptionListenerImpl.notifcationMap.clear();
    UDDISubscriptionListenerImpl.notificationCount = 0;
    Endpoint ep = null;
    boolean ok = false;
    do {
        try {
            logger.info("Attempting to bring up endpoint at " + "http://" + hostname + ":" + port
                    + "/UDDI_CALLBACK");
            ep = Endpoint.publish("http://" + hostname + ":" + port + "/UDDI_CALLBACK", impl);
            ok = true;
        } catch (Exception ex) {
            logger.warn("Trouble starting endpoint: " + ex.getMessage());
            port++;
        }
    } while (!ok);
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Joe's callback business");
    be.setBusinessServices(new BusinessServices());
    BusinessService bs = new BusinessService();
    bs.getName().add(new Name());
    bs.getName().get(0).setValue("Joe's callback service");
    bs.setBindingTemplates(new BindingTemplates());
    BindingTemplate bt = new BindingTemplate();
    bt.setAccessPoint(new AccessPoint());
    bt.getAccessPoint().setValue("http://" + hostname + ":" + port + "/UDDI_CALLBACK");
    bt.getAccessPoint().setUseType("endPoint");
    //Added per Kurt
    TModelInstanceInfo instanceInfo = new TModelInstanceInfo();
    instanceInfo.setTModelKey("uddi:uddi.org:transport:http");
    bt.setTModelInstanceDetails(new TModelInstanceDetails());
    bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo);

    bs.getBindingTemplates().getBindingTemplate().add(bt);

    bs.getBindingTemplates().getBindingTemplate().add(bt);
    be.getBusinessServices().getBusinessService().add(bs);
    sb.getBusinessEntity().add(be);
    BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);

    List<String> deleteme = new ArrayList<String>();
    deleteme.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
    //ok Joe's callback is setup

    //Setup a business to subscribe to
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Sam's business");
    sb.getBusinessEntity().add(be);
    BusinessDetail saveBusiness1 = publicationSam.saveBusiness(sb);

    //ok Joe now needs to subscribe for Sam's business
    Holder<List<Subscription>> list = new Holder<List<Subscription>>();
    list.value = new ArrayList<Subscription>();
    Subscription s = new Subscription();
    s.setBindingKey(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0)
            .getBindingTemplates().getBindingTemplate().get(0).getBindingKey());
    s.setSubscriptionFilter(new SubscriptionFilter());
    s.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
    s.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey()
            .add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    gcal.add(Calendar.HOUR, 1);
    s.setExpiresAfter(df.newXMLGregorianCalendar(gcal));

    s.setNotificationInterval(df.newDuration(5000));
    list.value.add(s);
    subscriptionJoe.saveSubscription(authInfoJoe, list);

    //ok have sam change his business around.
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = saveBusiness1.getBusinessEntity().get(0);
    be.getName().get(0).setLang("en");
    sb.getBusinessEntity().add(be);
    publicationSam.saveBusiness(sb);
    int maxwait = 30000;
    logger.info("waiting for callbacks");
    while (maxwait > 0) {
        if (UDDISubscriptionListenerImpl.notifcationMap.size() > 0) {
            break;
        }
        Thread.sleep(1000);
        maxwait = maxwait - 1000;
    }
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    this.DeleteBusinesses(deleteme, authInfoJoe, publicationJoe);
    deleteme.clear();
    deleteme.add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    this.DeleteBusinesses(deleteme, authInfoSam, publicationSam);
    ep.stop();
    if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) {
        Assert.fail("no callbacks were recieved.");
    }

}

From source file:org.apache.juddi.v3.tck.UDDI_141_JIRAIntegrationTest.java

/**
 * testing callbacks with undefined transport type with a uppercase path
 * this also tests the case of one user subscribing to a specific entity
 * via GetBusinessDetail subscription filter
 *
 * @throws Exception//from   w ww .  jav  a 2s  .c  o  m
 */
@Test
public void JIRA_596() throws Exception {
    Assume.assumeTrue(TckPublisher.isEnabled());
    System.out.println("JIRA_596");
    int port = 9000;

    String hostname = TckPublisher.getProperties().getProperty("bindaddress");
    if (hostname == null) {
        hostname = InetAddress.getLocalHost().getHostName();
    }

    // String localhostname = "localhost";//java.net.InetAddress.getLocalHost().getHostName();
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    //UDDISubscriptionListenerImpl impl = new UDDISubscriptionListenerImpl();
    UDDISubscriptionListenerImpl.notifcationMap.clear();
    UDDISubscriptionListenerImpl.notificationCount = 0;

    Endpoint ep = null;
    boolean ok = false;
    do {
        try {
            ep = Endpoint.publish("http://" + hostname + ":" + port + "/UDDI_CALLBACK", impl);
            ok = true;
        } catch (Exception ex) {
            port++;
        }
    } while (!ok);
    SaveBusiness sb = new SaveBusiness();
    sb.setAuthInfo(authInfoJoe);
    BusinessEntity be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Joe's callback business");
    be.setBusinessServices(new BusinessServices());
    BusinessService bs = new BusinessService();
    bs.getName().add(new Name());
    bs.getName().get(0).setValue("Joe's callback service");
    bs.setBindingTemplates(new BindingTemplates());
    BindingTemplate bt = new BindingTemplate();
    bt.setAccessPoint(new AccessPoint());
    bt.getAccessPoint().setValue("http://" + hostname + ":" + port + "/UDDI_CALLBACK");
    bt.getAccessPoint().setUseType("endPoint");
    //obmitted as part of the jira test case
    /*TModelInstanceInfo instanceInfo = new TModelInstanceInfo();
         instanceInfo.setTModelKey("uddi:uddi.org:transport:http");
         bt.setTModelInstanceDetails(new TModelInstanceDetails());
         bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo);
         */
    bs.getBindingTemplates().getBindingTemplate().add(bt);
    be.getBusinessServices().getBusinessService().add(bs);
    sb.getBusinessEntity().add(be);
    logger.info("setting up joe's callback business");
    BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb);

    List<String> deleteme = new ArrayList<String>();
    deleteme.add(saveBusiness.getBusinessEntity().get(0).getBusinessKey());
    //ok Joe's callback is setup

    //Setup a business to subscribe to
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = new BusinessEntity();
    be.getName().add(new Name());
    be.getName().get(0).setValue("Sam's business");
    sb.getBusinessEntity().add(be);
    logger.info("saving sam's business");
    BusinessDetail saveBusiness1 = publicationSam.saveBusiness(sb);

    //ok Joe now needs to subscribe for Sam's business
    Holder<List<Subscription>> list = new Holder<List<Subscription>>();
    list.value = new ArrayList<Subscription>();
    Subscription s = new Subscription();
    s.setBindingKey(saveBusiness.getBusinessEntity().get(0).getBusinessServices().getBusinessService().get(0)
            .getBindingTemplates().getBindingTemplate().get(0).getBindingKey());
    s.setSubscriptionFilter(new SubscriptionFilter());
    s.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
    s.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey()
            .add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    DatatypeFactory df = DatatypeFactory.newInstance();
    GregorianCalendar gcal = new GregorianCalendar();
    gcal.setTimeInMillis(System.currentTimeMillis());
    gcal.add(Calendar.HOUR, 1);
    s.setExpiresAfter(df.newXMLGregorianCalendar(gcal));

    s.setNotificationInterval(df.newDuration(5000));
    list.value.add(s);
    logger.info("subscribing joe's to updates for sam's business");
    subscriptionJoe.saveSubscription(authInfoJoe, list);

    //ok have sam change his business around.
    sb = new SaveBusiness();
    sb.setAuthInfo(authInfoSam);
    be = saveBusiness1.getBusinessEntity().get(0);
    be.getName().get(0).setLang("en");
    sb.getBusinessEntity().add(be);
    logger.info("altering sam's business");
    publicationSam.saveBusiness(sb);
    logger.info("Waiting...");
    int maxwait = 30000;
    while (maxwait > 0) {
        if (UDDISubscriptionListenerImpl.notifcationMap.size() > 0) {
            break;
        }
        Thread.sleep(1000);
        maxwait = maxwait - 1000;
    }
    TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
    DeleteBusinesses(deleteme, authInfoJoe, publicationJoe);
    deleteme.clear();
    deleteme.add(saveBusiness1.getBusinessEntity().get(0).getBusinessKey());
    DeleteBusinesses(deleteme, authInfoSam, publicationSam);
    ep.stop();
    if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) {
        logger.error("no callbacks were recieved");
        Assert.fail("no callbacks were recieved.");
    }
    logger.info("callback response was " + UDDISubscriptionListenerImpl.notifcationMap.get(0));
    logger.info("PASS");

}

From source file:org.apache.juddi.v3.tck.UDDI_170_ValueSetValidation.java

private void Reset() throws Exception {
    messagesReceived = 0;//  www. j a  v a2s .c o m
    if (ep == null || !ep.isPublished()) {
        int httpPort = 9600 + new Random().nextInt(99);
        String hostname = TckPublisher.getProperties().getProperty("bindaddress");
        if (hostname == null) {
            hostname = InetAddress.getLocalHost().getHostName();
        }
        url = "http://" + hostname + ":" + httpPort + "/" + UUID.randomUUID().toString();
        logger.info("Firing up embedded endpoint at " + url);
        do {
            try {

                ep = Endpoint.publish(url, this);
                httpPort = 9600 + new Random().nextInt(99);
            } catch (Exception ex) {
                logger.warn(ex.getMessage());
            }
        } while (ep != null && !ep.isPublished());

    }

}

From source file:org.fireflow.server.WorkflowServer.java

public void publishWorkflowEngineService() throws WebservicePublishException {
    Environment evn = runtimeContext.getDefaultEngineModule(Environment.class);
    String contextPath = evn.getWebserviceContextPath();
    if (!contextPath.startsWith("/")) {
        contextPath = "/" + contextPath;
    }/*  ww  w .ja va 2 s. c  o  m*/
    String address = "http://" + evn.getWebserviceIP() + ":" + Integer.toString(evn.getWebservicePort())
            + contextPath;

    WorkflowEngineService implementor = runtimeContext.getDefaultEngineModule(WorkflowEngineService.class);

    Endpoint.publish(address, implementor);
}

From source file:org.graphwalker.CLI.java

/**
 * Run the soap command//from   w w  w  .  j a  va2s. c o  m
 * 
 * @param cl
 * @throws StopConditionException
 * @throws GeneratorException
 * @throws IOException
 * @throws JDOMException
 * @throws InterruptedException
 */
private void RunCommandSoap(CommandLine cl)
        throws StopConditionException, GeneratorException, IOException, JDOMException, InterruptedException {
    String port = null;
    String nicAddr = null;
    if (cl.hasOption("p")) {
        port = cl.getOptionValue("p");
    } else {
        port = Util.readWSPort();
    }

    if (cl.hasOption("i")) {
        nicAddr = Util.getInternetAddr(cl.getOptionValue("i")).getCanonicalHostName();
    } else {
        nicAddr = "0.0.0.0";
    }

    String file = cl.getOptionValue("f");
    if (file == null || file.isEmpty()) {
        setMbt(new ModelBasedTesting());
    } else {
        setMbt(Util.loadMbtAsWSFromXml(Util.getFile(file)));
    }

    String wsURL = "http://" + nicAddr + ":" + port + "/mbt-services";
    SoapServices soapService = new SoapServices(getMbt());
    soapService.xmlFile = file;

    endpoint = Endpoint.publish(wsURL, soapService);

    if (nicAddr.equals("0.0.0.0")) {
        wsURL = wsURL.replace("0.0.0.0", InetAddress.getLocalHost().getHostName());
    }

    System.out.println("Now running as a SOAP server. For the WSDL file, see: " + wsURL + "?WSDL");
    System.out.println("Press Ctrl+C to quit");
    System.out.println("");
}