Skip to content
Snippets Groups Projects
Commit fbc6a705 authored by NTUMBA WA NTUMBA Patient's avatar NTUMBA WA NTUMBA Patient
Browse files

set inv addr test

parent 10097a45
No related branches found
No related tags found
No related merge requests found
package eu.chorevolution.vsb.examples_for_test.set_inv_addr_client;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
package eu.chorevolution.vsb.examples_for_test.set_inv_addr_client;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import eu.chorevolution.chors.Base;
import eu.chorevolution.chors.BaseService;
public class BaseServiceClient {
public static void main(String[] args) {
String bd_wsdl = "http://128.93.64.246:8080/vsb/baseService?wsdl";
String bc = "http://128.93.64.246:8080/vsb/baseService";
List<String> urls = new ArrayList<String>();
BaseService service;
try {
service = (BaseService) (Base.getPort("BaseService", bd_wsdl, bc, BaseService.class));
urls.add("http://localhost/test");
service.setInvocationAddress("dest_role", "dest_name", urls);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* Copyright 2015 The CHOReVOLUTION project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.chorevolution.vsb.examples_for_test.set_inv_addr_server;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.servlet.ServletContext;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
@WebService(
name = "ConfigurableService",
targetNamespace = "http://services.chorevolution.eu/"
)
public class Base implements BaseService {
protected String ENDPOINTADDRESS=null;
@Resource
private WebServiceContext context;
private static List<URL> endpoints = new ArrayList<URL>();
/**
* Each BasicService subclass has the following lifecycle:
* 1. start the service
* 2. send it its own enpoint address
* 3. send the service dependency data (according to Enactment Engine choreography requirements)
* */
public Base(){
}
/* (non-Javadoc)
* @see org.choreos.services.Base#setInvocationAddress(java.lang.String, java.lang.String)
*/
/* (non-Javadoc)
* @see eu.chorevolution.enactment.dependencies.ConfigurableService#setInvocationAddress(java.lang.String, java.lang.String, java.util.List)
*/
@WebMethod
public void setInvocationAddress(String role, String name, List<String> endpoints) {
System.out.println("SERVICE CALLED");
//System.out.println("setting inv. addrr to "+ endpoints);
System.out.println("role "+ role);
System.out.println("name "+ name);
if (endpoints.size()>0){
System.out.println("set the invocatin address to : " + endpoints.get(0));
}
}
/**
* Example call: (Client1) (getPort("Client1", "http://localhost/client1?wsdl", Client1.class));
* @throws MalformedURLException
* */
public static <T> T getPort(String service_name, String wsdlLocation, Class<T> client_class) throws MalformedURLException{
T retPort = null;
QName serviceQName = null;
URL serviceUrl = null;
Service s;
serviceQName = new QName(namespace, service_name+"Service");
serviceUrl = new URL(wsdlLocation);
s = Service.create(serviceUrl, serviceQName);
retPort=(T) s.getPort(client_class);
return retPort;
}
}
/**
* Copyright 2015 The CHOReVOLUTION project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.chorevolution.vsb.examples_for_test.set_inv_addr_server;
import java.util.List;
public interface BaseService {
public final static String namespace="http://services.chorevolution.eu/";
/* (non-Javadoc)
* @see org.choreos.services.Base#setInvocationAddress(java.lang.String, java.lang.String)
*/
void setInvocationAddress(String role, String name, List<String> endpoints);
}
\ No newline at end of file
package eu.chorevolution.vsb.examples_for_test.set_inv_addr_server;
import javax.xml.ws.Endpoint;
public class BaseServicePublisher {
public static void main(String[] args) {
// TODO Auto-generated method stub
Endpoint.publish("http://128.93.64.246:8080/vsb/baseService", new Base());
System.out.println("Service is published!");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment