Skip to content
Snippets Groups Projects
Commit 3fde6fca authored by boulouk's avatar boulouk
Browse files

creating java web service from wsdl file for setInvocationAddress

parent fa46b5b1
No related branches found
No related tags found
No related merge requests found
Showing
with 402 additions and 137 deletions
......@@ -59,11 +59,7 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.chorevolution.ee</groupId>
<artifactId>chorspec</artifactId>
<version>1.0.0</version>
</dependency>
<!--
<dependency>
......
package eu.chorevolution.services;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "BaseService", targetNamespace = "http://services.chorevolution.eu/", wsdlLocation = "file:/D:/inria/code/repositories/chorevolution/evolution-service-bus/scenarios-end-to-end-test/src/main/resources/BaseService.wsdl")
public class BaseService
extends Service
{
private final static URL BASESERVICE_WSDL_LOCATION;
private final static WebServiceException BASESERVICE_EXCEPTION;
private final static QName BASESERVICE_QNAME = new QName("http://services.chorevolution.eu/", "BaseService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("file:/D:/inria/code/repositories/chorevolution/evolution-service-bus/scenarios-end-to-end-test/src/main/resources/BaseService.wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
BASESERVICE_WSDL_LOCATION = url;
BASESERVICE_EXCEPTION = e;
}
public BaseService() {
super(__getWsdlLocation(), BASESERVICE_QNAME);
}
public BaseService(WebServiceFeature... features) {
super(__getWsdlLocation(), BASESERVICE_QNAME, features);
}
public BaseService(URL wsdlLocation) {
super(wsdlLocation, BASESERVICE_QNAME);
}
public BaseService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, BASESERVICE_QNAME, features);
}
public BaseService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public BaseService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns ConfigurableService
*/
@WebEndpoint(name = "ConfigurableServicePort")
public ConfigurableService getConfigurableServicePort() {
return super.getPort(new QName("http://services.chorevolution.eu/", "ConfigurableServicePort"), ConfigurableService.class);
}
/**
*
* @param features
* A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns ConfigurableService
*/
@WebEndpoint(name = "ConfigurableServicePort")
public ConfigurableService getConfigurableServicePort(WebServiceFeature... features) {
return super.getPort(new QName("http://services.chorevolution.eu/", "ConfigurableServicePort"), ConfigurableService.class, features);
}
private static URL __getWsdlLocation() {
if (BASESERVICE_EXCEPTION!= null) {
throw BASESERVICE_EXCEPTION;
}
return BASESERVICE_WSDL_LOCATION;
}
}
package eu.chorevolution.services;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.Action;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebService(name = "ConfigurableService", targetNamespace = "http://services.chorevolution.eu/")
@XmlSeeAlso({
ObjectFactory.class
})
public interface ConfigurableService {
/**
*
* @param arg2
* @param arg1
* @param arg0
*/
@WebMethod
@RequestWrapper(localName = "setInvocationAddress", targetNamespace = "http://services.chorevolution.eu/", className = "eu.chorevolution.services.SetInvocationAddress")
@ResponseWrapper(localName = "setInvocationAddressResponse", targetNamespace = "http://services.chorevolution.eu/", className = "eu.chorevolution.services.SetInvocationAddressResponse")
@Action(input = "http://services.chorevolution.eu/ConfigurableService/setInvocationAddressRequest", output = "http://services.chorevolution.eu/ConfigurableService/setInvocationAddressResponse")
public void setInvocationAddress(
@WebParam(name = "arg0", targetNamespace = "")
String arg0,
@WebParam(name = "arg1", targetNamespace = "")
String arg1,
@WebParam(name = "arg2", targetNamespace = "")
List<String> arg2);
}
package eu.chorevolution.services;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the eu.chorevolution.services package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _SetInvocationAddress_QNAME = new QName("http://services.chorevolution.eu/", "setInvocationAddress");
private final static QName _SetInvocationAddressResponse_QNAME = new QName("http://services.chorevolution.eu/", "setInvocationAddressResponse");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: eu.chorevolution.services
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link SetInvocationAddressResponse }
*
*/
public SetInvocationAddressResponse createSetInvocationAddressResponse() {
return new SetInvocationAddressResponse();
}
/**
* Create an instance of {@link SetInvocationAddress }
*
*/
public SetInvocationAddress createSetInvocationAddress() {
return new SetInvocationAddress();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link SetInvocationAddress }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://services.chorevolution.eu/", name = "setInvocationAddress")
public JAXBElement<SetInvocationAddress> createSetInvocationAddress(SetInvocationAddress value) {
return new JAXBElement<SetInvocationAddress>(_SetInvocationAddress_QNAME, SetInvocationAddress.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link SetInvocationAddressResponse }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://services.chorevolution.eu/", name = "setInvocationAddressResponse")
public JAXBElement<SetInvocationAddressResponse> createSetInvocationAddressResponse(SetInvocationAddressResponse value) {
return new JAXBElement<SetInvocationAddressResponse>(_SetInvocationAddressResponse_QNAME, SetInvocationAddressResponse.class, null, value);
}
}
package eu.chorevolution.services;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for setInvocationAddress complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="setInvocationAddress">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="arg1" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="arg2" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "setInvocationAddress", propOrder = {
"arg0",
"arg1",
"arg2"
})
public class SetInvocationAddress {
protected String arg0;
protected String arg1;
protected List<String> arg2;
/**
* Gets the value of the arg0 property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getArg0() {
return arg0;
}
/**
* Sets the value of the arg0 property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setArg0(String value) {
this.arg0 = value;
}
/**
* Gets the value of the arg1 property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getArg1() {
return arg1;
}
/**
* Sets the value of the arg1 property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setArg1(String value) {
this.arg1 = value;
}
/**
* Gets the value of the arg2 property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the arg2 property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getArg2().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link String }
*
*
*/
public List<String> getArg2() {
if (arg2 == null) {
arg2 = new ArrayList<String>();
}
return this.arg2;
}
}
package eu.chorevolution.services;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for setInvocationAddressResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="setInvocationAddressResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "setInvocationAddressResponse")
public class SetInvocationAddressResponse {
}
@javax.xml.bind.annotation.XmlSchema(namespace = "http://services.chorevolution.eu/")
package eu.chorevolution.services;
package eu.chorevolution.vsb.test.baseService;
import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
import eu.chorevolution.services.ConfigurableService;
@WebService( endpointInterface="eu.chorevolution.services.ConfigurableService", serviceName="BaseService")
public class BaseServiceImpl implements ConfigurableService {
@Override
public void setInvocationAddress(String arg0, String arg1, List<String> arg2) {
System.out.println("amleto");
}
}
......@@ -2,14 +2,12 @@ package eu.chorevolution.vsb.test.baseService;
import javax.xml.ws.Endpoint;
import eu.chorevolution.chors.Base;
public class BaseServicePublisher {
public static void main(String[] args) {
// TODO Auto-generated method stub
Endpoint.publish("http://localhost:9999/vsb/baseService", new Base());
Endpoint.publish("http://localhost:9999/vsb/baseService", new BaseServiceImpl());
System.out.println("WebServivce is running on port 9999");
}
......
package eu.chorevolution.vsb.test.baseService;
import java.util.List;
public interface BaseServiceTmp {
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.test.baseService;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
@WebService(
name = "BaseService",
targetNamespace = "http://services.chorevolution.eu/"
)
public class BaseTmp implements BaseServiceTmp {
protected Map<String,String> address_map=null;
protected String ENDPOINTADDRESS=null;
/**
* 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 BaseTmp(){
address_map = new HashMap<String, String>();
}
/* (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("Receive... role:"+role+" name:"+name+" endpoints:"+endpoints.get(0));
if (address_map.containsKey(name)) {
address_map.remove(name);
}
address_map.put(name, 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;
}
}
package eu.chorevolution.vsb.test.baseServiceClient;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.soap.SOAPBinding;
import eu.chorevolution.chors.Base;
import eu.chorevolution.chors.BaseService;
import eu.chorevolution.services.BaseService;
import eu.chorevolution.services.ConfigurableService;
//import eu.chorevolution.vsb.test.baseService.BaseTmp;
//import eu.chorevolution.vsb.test.baseService.BaseServiceTmp;
public class baseServiceClient {
public static void main(String[] args) {
// TODO Auto-generated method stub
URL url = null;
try {
url = new URL("http://localhost:9999/vsb/baseService?wsdl");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// QName qname = new QName("http://services.chorevolution.eu/", "BaseService");
//
// Service service = Service.create(url, qname);
// BaseService base = service.getPort(qname,BaseService.class);
//
String dest_role = "baseService";
String dest_name = "baseService";
List<String> urls = new ArrayList<String>();
urls.add("192.168.106.20");
// base.setInvocationAddress(role, name, endpoints);
BaseService service;
try {
service = Base.getPort("Base", "http://localhost:9999/vsb/baseService?wsdl", "http://localhost:9999/vsb/baseService", BaseService.class);
service.setInvocationAddress(dest_role, dest_name, urls);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
BaseService service = new BaseService();
ConfigurableService port = service.getConfigurableServicePort();
List<String> endpoints = new ArrayList<String>();
//port.setInvocationAddress("role", "test");
port.setInvocationAddress("role", "test", endpoints);
}
}
\ No newline at end of file
......@@ -12,7 +12,9 @@
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
<xs:element name="arg1" type="xs:string" minOccurs="0"/>
<xs:element name="arg2" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
......@@ -47,7 +49,7 @@
</binding>
<service name="BaseService">
<port name="ConfigurableServicePort" binding="tns:ConfigurableServicePortBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
<soap:address location="http://localhost:9999/vsb/baseService"/>
</port>
</service>
</definitions>
......
String interfaceDescriptionPath = "D://inria//code//repositories//chorevolution//evolution-service-bus//bc-manager//src//main//resources//weather.gidl";
wsimport -d . -s .\java .\resources\BaseService.wsdl
\ No newline at end of file
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