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

updat dpws in playground project

parent 0daabf5e
No related branches found
No related tags found
No related merge requests found
Showing
with 111 additions and 585 deletions
<?xml version="1.0" encoding="UTF-8"?>
<gidl:GIDLModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gidl="http://eu.chorevolution/modelingnotations/gidl" hostAddress="http://jinx.viktoria.chalmers.se:3001/" protocol="REST">
<hasInterfaces role="provider">
<hasOperations name="bridgeNextClosure" type="two_way_sync" qos="reliable">
<hasScope name="bridgeNextClosure" verb="POST" uri="bridgeNextClosure"/>
<inputData name="request" context="body">
<hasDataType xsi:type="gidl:ComplexType" name="RequestRoot" occurences="one">
<hasDataType xsi:type="gidl:ComplexType" name="bridgeStatusInformationRequest" occurences="one">
<hasDataType xsi:type="gidl:ComplexType" name="origin" occurences="one">
<hasDataType xsi:type="gidl:SimpleType" name="lat" occurences="one" type="string"/>
<hasDataType xsi:type="gidl:SimpleType" name="lon" occurences="one" type="string"/>
</hasDataType>
<hasDataType xsi:type="gidl:ComplexType" name="destination" occurences="one">
<hasDataType xsi:type="gidl:SimpleType" name="lat" occurences="one" type="string"/>
<hasDataType xsi:type="gidl:SimpleType" name="lon" occurences="one" type="string"/>
</hasDataType>
</hasDataType>
</hasDataType>
</inputData>
<outputData name="response" context="body">
<hasDataType xsi:type="gidl:ComplexType" name="ResponseRoot" occurences="one">
<hasDataType xsi:type="gidl:ComplexType" name="bridgeStatusInformationResponse" occurences="one">
<hasDataType xsi:type="gidl:ComplexType" name="closureStatus" occurences="one">
<hasDataType xsi:type="gidl:SimpleType" name="isClosed" occurences="one" type="boolean"/>
<hasDataType xsi:type="gidl:SimpleType" name="opensAtTimeMillis" occurences="one" type="string"/>
</hasDataType>
<hasDataType xsi:type="gidl:ComplexType" name="nextClosure" occurences="one">
<hasDataType xsi:type="gidl:SimpleType" name="fromMillis" occurences="one" type="string"/>
<hasDataType xsi:type="gidl:SimpleType" name="toMillis" occurences="one" type="string"/>
</hasDataType>
</hasDataType>
</hasDataType>
</outputData>
</hasOperations>
</hasInterfaces>
</gidl:GIDLModel>
......@@ -60,7 +60,6 @@ public class CoapClientPart {
client.startClient("coap://127.0.0.1:9082", "hello");
client.post_oneway("coap://127.0.0.1:9082", "oneway", "post_oneway hello", 10000);
client.post_twoway("coap://127.0.0.1:9082", "twoway", "post_twoway hello", 10000);
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpws;
import org.ws4d.java.communication.CommunicationException;
import org.ws4d.java.constants.SchemaConstants;
import org.ws4d.java.schema.Attribute;
import org.ws4d.java.schema.ComplexType;
import org.ws4d.java.schema.Element;
import org.ws4d.java.schema.ExtendedSimpleContent;
import org.ws4d.java.schema.SchemaUtil;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.QName;
import org.ws4d.java.communication.CommunicationException;
import org.ws4d.java.constants.SchemaConstants;
import org.ws4d.java.schema.Attribute;
import org.ws4d.java.schema.ComplexType;
import org.ws4d.java.schema.Element;
import org.ws4d.java.schema.ExtendedSimpleContent;
import org.ws4d.java.schema.SchemaUtil;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.QName;
public class DocuExampleAttributeOperation extends Operation {
/**
* Constructor
*/
public DocuExampleAttributeOperation() {
super("DocuExampleAttributeOperation", new QName("BasicServices", DocuExampleDevice.DOCU_NAMESPACE));
/* use this code to add an attribute to a simple type element. */
{
// create new Attribute called "gender"
Attribute genderAttr = new Attribute(new QName("gender", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
genderAttr.setUse(SchemaConstants.USE_OPTIONAL);
// create extended simple content type
ExtendedSimpleContent simpleCon = new ExtendedSimpleContent("simpleContent", DocuExampleDevice.DOCU_NAMESPACE);
simpleCon.setBase(SchemaUtil.TYPE_STRING);
simpleCon.addAttributeElement(genderAttr);
// // create new element with the extended simple content type
// Element simpleConNameElem = new Element(new QName("firstName",
// DocuExampleDevice.DOCU_NAMESPACE), simpleCon);
//
// // set the input of the operation
// setInput(simpleConNameElem);
}
/* use this code to add an attribute to a complex type element. */
{
// create inner elements
Element street = new Element(new QName("street", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
Element zip = new Element(new QName("zip", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_INT);
Element city = new Element(new QName("city", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
Element country = new Element(new QName("country", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
// create attribute
Attribute name = new Attribute(new QName("name", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
name.setUse(SchemaUtil.USE_REQUIRED);
// create complex type
ComplexType addressType = new ComplexType(new QName("addressType", DocuExampleDevice.DOCU_NAMESPACE), ComplexType.CONTAINER_SEQUENCE);
// add inner elements
addressType.addElement(street);
addressType.addElement(zip);
addressType.addElement(city);
addressType.addElement(country);
// add attribute
addressType.addAttributeElement(name);
// create element of type address
Element adress = new Element(new QName("address", DocuExampleDevice.DOCU_NAMESPACE), addressType);
// set the input of the operation
setInput(adress);
}
}
public ParameterValue invokeImpl(ParameterValue parameterValue, CredentialInfo credentialInfo) throws InvocationException, CommunicationException {
// use this code to get an attribute from simple type element
// String attribute = ParameterUtil.getAttributeValue(parameterValue,
// null, "sex");
// use this code to get an attribute from complex type element
String attribute = ParameterValueManagement.getAttributeValue(parameterValue, null, new QName("name"));
System.out.println("attribute: " + attribute);
return null;
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpws;
import org.ws4d.java.communication.CommunicationException;
import org.ws4d.java.schema.ComplexType;
import org.ws4d.java.schema.Element;
import org.ws4d.java.schema.SchemaUtil;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.QName;
public class DocuExampleComplexOperation extends Operation {
public DocuExampleComplexOperation() {
super("DocuExampleComplexOperation", new QName("BasicServices", DocuExampleDevice.DOCU_NAMESPACE));
// create inner elements for complex type
Element nameElem = new Element(new QName("name", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
Element addressElem = new Element(new QName("address", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
addressElem.setMaxOccurs(2);
// create complex type and add inner elements
ComplexType userInfo = new ComplexType(new QName("userInfoType", DocuExampleDevice.DOCU_NAMESPACE), ComplexType.CONTAINER_SEQUENCE);
userInfo.addElement(nameElem);
userInfo.addElement(addressElem);
// create element of type userInfo
Element userInfoElement = new Element(new QName("userInfo", DocuExampleDevice.DOCU_NAMESPACE), userInfo);
// set the input of the operation
setInput(userInfoElement);
// create reply element
Element reply = new Element(new QName("reply", DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
// set this element as output
setOutput(reply);
}
public ParameterValue invokeImpl(ParameterValue parameterValue, CredentialInfo credentialInfo) throws InvocationException, CommunicationException {
// get string value from input
String name = ParameterValueManagement.getString(parameterValue, "name");
String address = ParameterValueManagement.getString(parameterValue, "address[0]");
String address2 = ParameterValueManagement.getString(parameterValue, "address[1]");
System.out.println("Hello World " + name + " from " + address + " or " + address2);
// create output and set value
ParameterValue result = createOutputValue();
ParameterValueManagement.setString(result, "reply", "How are you " + name + " from " + address + " and other places?");
return result;
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpws;
import org.ws4d.java.communication.DPWSCommunicationManager;
import org.ws4d.java.service.DefaultDevice;
import org.ws4d.java.types.LocalizedString;
import org.ws4d.java.types.QName;
import org.ws4d.java.types.QNameSet;
public class DocuExampleDevice extends DefaultDevice {
public class DocuExampleDevice extends DefaultDevice{
public final static String DOCU_NAMESPACE = "http://ws4d.org/jmeds";
/**
* Constructor of our device.
*/
public DocuExampleDevice() {
super(DPWSCommunicationManager.COMMUNICATION_MANAGER_ID);
/*
* The following lines add metadata information to the device to
* illustrate how it works. As default values are defined for all of the
* fields, you CAN set new values here but you do NOT have to.
*/
// set PortType
public DocuExampleDevice(){
super();
this.setPortTypes(new QNameSet(new QName("DocuExampleDevice", DOCU_NAMESPACE)));
// add device name (name is language specific)
this.addFriendlyName("en-US", "DocuDevice");
this.addFriendlyName(LocalizedString.LANGUAGE_DE, "DokuGeraet");
// add device manufacturer (manufacturer is language specific)
this.addManufacturer(LocalizedString.LANGUAGE_EN, "Test Inc.");
this.addManufacturer("de-DE", "Test GmbH");
this.addModelName(LocalizedString.LANGUAGE_EN, "DocuModel");
// add binding (optional!)
/*
* add discovery binding or change the ip (127.0.0.1) with an ip of a
* non loopback interface like eth1 or eth3
*/
// NetworkInterface iface =
// IPNetworkDetection.getInstance().getNetworkInterface("eth3");
// IPDiscoveryDomain domain =
// IPNetworkDetection.getInstance().getIPDiscoveryDomainForInterface(iface,
// false);
// this.addBinding(new
// IPDiscoveryBinding(DPWSCommunicationManager.COMMUNICATION_MANAGER_ID,
// domain));
// this.addBinding(new
// HTTPBinding(IPNetworkDetection.getInstance().getIPAddressOfAnyLocalInterface("127.0.0.1",
// false), 0, "docuDevice",
// DPWSCommunicationManager.COMMUNICATION_MANAGER_ID));
//
// NetworkInterface iface = IPNetworkDetection.getInstance().getNetworkInterface("eno1");
// IPDiscoveryDomain domain = IPNetworkDetection.getInstance().getIPDiscoveryDomainForInterface(iface, false);
// this.addBinding(new IPDiscoveryBinding(DPWSCommunicationManager.COMMUNICATION_MANAGER_ID, domain));
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpws;
import org.ws4d.java.JMEDSFramework;
import org.ws4d.java.client.DefaultClient;
import org.ws4d.java.client.SearchManager;
import org.ws4d.java.communication.CommunicationException;
import org.ws4d.java.communication.DPWSCommunicationManager;
import org.ws4d.java.communication.DPWSProtocolVersion;
import org.ws4d.java.configuration.DPWSProperties;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.Device;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.service.reference.DeviceReference;
import org.ws4d.java.service.reference.ServiceReference;
import org.ws4d.java.types.LocalizedString;
import org.ws4d.java.types.QName;
import org.ws4d.java.types.QNameSet;
import org.ws4d.java.types.SearchParameter;
/**
* Sample client for searching devices and services.
*/
public class DocuExampleSearchClient extends DefaultClient {
final static String namespace = DocuExampleDevice.DOCU_NAMESPACE;
final static QName service = new QName("BasicServices", namespace);
public static void main(String[] args) {
// mandatory starting of DPWS framework
JMEDSFramework.start(args);
DPWSProperties.getInstance().removeSupportedDPWSVersion(DPWSProtocolVersion.DPWS_VERSION_2006);
// create client
DocuExampleSearchClient client = new DocuExampleSearchClient();
// Use discovery, define what you are searching for and start search
SearchParameter search = new SearchParameter();
search.setDeviceTypes(new QNameSet(new QName("DocuExampleDevice", namespace)), DPWSCommunicationManager.COMMUNICATION_MANAGER_ID);
SearchManager.searchDevice(search, client, null);
// search services
search = new SearchParameter();
search.setServiceTypes(new QNameSet(service), DPWSCommunicationManager.COMMUNICATION_MANAGER_ID);
SearchManager.searchService(search, client, null);
// // Use without discovery
// EndpointReference epr = new EndpointReference(new AttributedURI("urn:uuid:f2a17540-9a22-11e3-bf1e-3c73ae043d4b"));
// XAddressInfo xAddress = new XAddressInfo(new URI("http://[0:0:0:0:0:0:0:1]:58410/f2a17540-9a22-11e3-bf1e-3c73ae043d4b"));
// xAddress.setProtocolInfo(new DPWSProtocolInfo(DPWSProtocolVersion.DPWS_VERSION_2009));
// XAddressInfoSet addresses = new XAddressInfoSet(xAddress);
//
// DeviceReference defRef = DeviceServiceRegistry.getDeviceReference(epr, addresses, DPWSCommunicationManager.COMMUNICATION_MANAGER_ID, true);
// try {
// Device dev = defRef.getDevice();
// // we know the searched service's id
// DefaultServiceReference sRef = (DefaultServiceReference) dev.getServiceReference(DocuExampleService.DOCU_EXAMPLE_SERVICE_ID, SecurityKey.EMPTY_KEY);
// Service serv = sRef.getService();
//
// // we are looking for an Operation by its name
// Operation op = serv.getOperation(null, "DocuExampleSimpleOperation", null, null);
//
// ParameterValue input = op.createInputValue();
// ParameterValueManagement.setString(input, DocuExampleSimpleOperation.NAME, "Number One");
//
// ParameterValue result;
// try {
// result = op.invoke(input, CredentialInfo.EMPTY_CREDENTIAL_INFO);
// System.out.println("Response from the DocuExampleSimpleOperation: " + result.toString());
// } catch (AuthorizationException e) {
// e.printStackTrace();
// } catch (InvocationException e) {
// e.printStackTrace();
// }
// } catch (CommunicationException e) {
// e.printStackTrace();
// }
}
public void serviceFound(ServiceReference servRef, SearchParameter search, String comManId) {
try {
// use this code to call the DokuExampleSimplestOperation
// {
// // get Operation
// Operation op = servRef.getService().getOperation(service, "DocuExampleSimpleOperation", null, null);
//
// // create input value and set string value
// ParameterValue request = op.createInputValue();
// ParameterValueManagement.setString(request, "name", "Bobby");
//
// System.err.println("Invoking HelloWorldOp...");
//
// // invoke operation with prepared input
// ParameterValue result = op.invoke(request, CredentialInfo.EMPTY_CREDENTIAL_INFO);
//
// // get string value from answer
// String reply = ParameterValueManagement.getString(result, "reply");
//
// System.err.println(reply);
// }
// use this code to call the DokuExampleComplexOperation
{
// get operation
Operation op = servRef.getService().getOperation(service, "DocuExampleComplexOperation", null, null);
// create input value and set string values
ParameterValue request = op.createInputValue();
ParameterValueManagement.setString(request, "name", "Bobby");
ParameterValueManagement.setString(request, "address[0]", "2500 University Blvd.");
ParameterValueManagement.setString(request, "address[1]", "263 Laurent");
System.err.println("Invoking HelloWorldOp...");
// invoke operation with prepared input
ParameterValue result = op.invoke(request, CredentialInfo.EMPTY_CREDENTIAL_INFO);
System.err.println("Finished invoking HelloWorldOp...");
// get string value from answer
String reply = ParameterValueManagement.getString(result, "reply");
System.out.println("reply is : "+reply);
}
} catch (CommunicationException e){
e.printStackTrace();
} catch (InvocationException e){
e.printStackTrace();
}
}
public void deviceFound(DeviceReference devRef, SearchParameter search, String comManId) {
try {
Device device = devRef.getDevice();
System.out.println("Found DocuExampleDevice: " + device.getFriendlyName(LocalizedString.LANGUAGE_EN));
} catch (CommunicationException e) {
e.printStackTrace();
}
}
};
package eu.chorevolution.vsb.playgrounds.clientserver.dpws;
import org.ws4d.java.communication.DPWSCommunicationManager;
import org.ws4d.java.service.DefaultService;
import org.ws4d.java.types.URI;
......@@ -18,21 +17,20 @@ public class DocuExampleService extends DefaultService {
/**
* Standard Constructor
*/
public DocuExampleService() {
super();
this.setServiceId(DOCU_EXAMPLE_SERVICE_ID);
// (tutorial 2) add Operations from tutorial 2 to the service
DocuExampleSimpleOperation simpleOp = new DocuExampleSimpleOperation();
addOperation(simpleOp);
DocuExampleComplexOperation complexOp = new DocuExampleComplexOperation();
/* DocuExampleComplexOperation complexOp = new DocuExampleComplexOperation();
addOperation(complexOp);
DocuExampleAttributeOperation attrOp = new DocuExampleAttributeOperation();
addOperation(attrOp);
addOperation(attrOp);*/
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpws;
import java.io.IOException;
import org.ws4d.java.JMEDSFramework;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.types.QName;
public class DocuExampleServiceProvider {
/**
* @param args
*/
public static void main(String[] args) {
// DPWSProperties.getInstance().setSOAPMessageGeneratorFactoryClass(EXISOAPMessageGeneratorFactory.class.getName());
// XXX: add DPWS_EXI Project from Framework-Add-ons to build path
// mandatory: Starting the DPWS Framework.
JMEDSFramework.start(args);
// First we need a device.
DocuExampleDevice device = new DocuExampleDevice();
// Then we create a service.
final DocuExampleService service = new DocuExampleService();
// Add a very very simple operation to the service.
service.addOperation(new Operation("DocuHelloWorldOp", new QName("BasicServices", DocuExampleDevice.DOCU_NAMESPACE)) {
// we have to implement the invoke method
public ParameterValue invokeImpl(ParameterValue pv, CredentialInfo localCredentialInfo) throws InvocationException {
// all we want to do is to print Hello World!
System.out.println("HelloWorld!");
return pv;
}
});
// In the end we add our service to the device.
device.addService(service);
// Do not forget to start the device!
try {
device.start();
if(device.isRunning()){
System.out.println("Device started !");
}
} catch (IOException e){
e.printStackTrace();
}
}
}
......@@ -10,48 +10,33 @@ import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.QName;
/**
* Implementation of the first operation described in "An Introduction to WS4D
* and to JMEDS, a framework for distributed communication between devices in a
* domotic environment" by Pierre-Alexandre GagnÈ
*
* @author ajordan
*/
public class DocuExampleSimpleOperation extends Operation {
import eu.chorevolution.vsb.playgrounds.clientserver.dpws.DocuExampleDevice;
public final static String NAME = "name";
public class DocuExampleSimpleOperation extends Operation {
public final static String NAME = "name";
public final static String REPLY = "reply";
/**
* Constructor
*/
public DocuExampleSimpleOperation() {
// TODO Auto-generated constructor stub
super("DocuExampleSimpleOperation", new QName("BasicServices", DocuExampleDevice.DOCU_NAMESPACE));
// create new Element called "name" (just a simple one in this case)
Element nameElem = new Element(new QName(NAME, DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
// set the input of the operation
setInput(nameElem);
// create new element called "reply"
Element reply = new Element(new QName(REPLY, DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
// set this element as output
setOutput(reply);
}
public ParameterValue invokeImpl(ParameterValue parameterValue, CredentialInfo credentialInfo) throws InvocationException, CommunicationException {
// get string value from input
String name = ParameterValueManagement.getString(parameterValue, NAME);
System.out.println("You have the brigde, " + name);
// create output and set value
ParameterValue result = createOutputValue();
ParameterValueManagement.setString(result, REPLY, "You have the brigde, " + name);
@Override
protected ParameterValue invokeImpl(ParameterValue arg0, CredentialInfo arg1)
throws InvocationException, CommunicationException {
// TODO Auto-generated method stub
String name = ParameterValueManagement.getString(arg0, "name");
System.err.println("Get request : name="+name);
ParameterValue result = createOutputValue();
ParameterValueManagement.setString(result, REPLY, "How are you "+name+" ? ");
System.err.println("Send response : "+REPLY+"="+"How are you "+name+" ? ");
return result;
}
......
package eu.chorevolution.vsb.playgrounds.clientserver.dpwsExample;
import org.ws4d.java.service.DefaultDevice;
import org.ws4d.java.types.LocalizedString;
import org.ws4d.java.types.QName;
import org.ws4d.java.types.QNameSet;
public class DocuExampleDevice extends DefaultDevice{
public final static String DOCU_NAMESPACE = "http://ws4d.org/jmeds";
public DocuExampleDevice(){
super();
this.setPortTypes(new QNameSet(new QName("DocuExampleDevice", DOCU_NAMESPACE)));
this.addFriendlyName("en-US", "DocuDevice");
this.addFriendlyName(LocalizedString.LANGUAGE_DE, "DokuGeraet");
this.addManufacturer(LocalizedString.LANGUAGE_EN, "Test Inc.");
this.addManufacturer("de-DE", "Test GmbH");
this.addModelName(LocalizedString.LANGUAGE_EN, "DocuModel");
//
// NetworkInterface iface = IPNetworkDetection.getInstance().getNetworkInterface("eno1");
// IPDiscoveryDomain domain = IPNetworkDetection.getInstance().getIPDiscoveryDomainForInterface(iface, false);
// this.addBinding(new IPDiscoveryBinding(DPWSCommunicationManager.COMMUNICATION_MANAGER_ID, domain));
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpwsExample;
import org.ws4d.java.service.DefaultService;
import org.ws4d.java.types.URI;
/**
* Implementation of the service described in "An Introduction to WS4D and to
* JMEDS, a framework for distributed communication between devices in a domotic
* environment" by Pierre-Alexandre GagnÈ
*
* @author ajordan
*/
public class DocuExampleService extends DefaultService {
public final static URI DOCU_EXAMPLE_SERVICE_ID = new URI(DocuExampleDevice.DOCU_NAMESPACE + "/DocuExampleService");
/**
* Standard Constructor
*/
public DocuExampleService() {
super();
this.setServiceId(DOCU_EXAMPLE_SERVICE_ID);
DocuExampleSimpleOperation simpleOp = new DocuExampleSimpleOperation();
addOperation(simpleOp);
/* DocuExampleComplexOperation complexOp = new DocuExampleComplexOperation();
addOperation(complexOp);
DocuExampleAttributeOperation attrOp = new DocuExampleAttributeOperation();
addOperation(attrOp);*/
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpwsExample;
import org.ws4d.java.communication.CommunicationException;
import org.ws4d.java.schema.Element;
import org.ws4d.java.schema.SchemaUtil;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.QName;
import eu.chorevolution.vsb.playgrounds.clientserver.dpws.DocuExampleDevice;
public class DocuExampleSimpleOperation extends Operation {
public final static String NAME = "name";
public final static String REPLY = "reply";
public DocuExampleSimpleOperation() {
// TODO Auto-generated constructor stub
super("DocuExampleSimpleOperation", new QName("BasicServices", DocuExampleDevice.DOCU_NAMESPACE));
Element nameElem = new Element(new QName(NAME, DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
setInput(nameElem);
Element reply = new Element(new QName(REPLY, DocuExampleDevice.DOCU_NAMESPACE), SchemaUtil.TYPE_STRING);
setOutput(reply);
}
@Override
protected ParameterValue invokeImpl(ParameterValue arg0, CredentialInfo arg1)
throws InvocationException, CommunicationException {
// TODO Auto-generated method stub
String name = ParameterValueManagement.getString(arg0, "name");
System.err.println("Get request : name="+name);
ParameterValue result = createOutputValue();
ParameterValueManagement.setString(result, REPLY, "How are you "+name+" ? ");
System.err.println("Send response : "+REPLY+"="+"How are you "+name+" ? ");
return result;
}
}
package eu.chorevolution.vsb.playgrounds.clientserver.dpwsExample;
package eu.chorevolution.vsb.playgrounds.clientserver.testdpws;
import org.ws4d.java.JMEDSFramework;
import org.ws4d.java.client.DefaultClient;
......@@ -16,6 +16,9 @@ import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.service.reference.DeviceReference;
import org.ws4d.java.service.reference.ServiceReference;
import org.ws4d.java.types.SearchParameter;
import eu.chorevolution.vsb.playgrounds.clientserver.dpws.DocuExampleDevice;
import org.ws4d.java.types.LocalizedString;
import org.ws4d.java.types.QName;
import org.ws4d.java.types.QNameSet;
......@@ -38,12 +41,12 @@ public class DocuExampleSearchClient extends DefaultClient {
searchParameter.setDeviceTypes(new QNameSet(deviceQname), DPWSCommunicationManager.COMMUNICATION_MANAGER_ID);
SearchManager.searchDevice(searchParameter, client, null);
System.err.println("Begin search services ");
System.err.println("Begin search services");
// search services
searchParameter = new SearchParameter();
searchParameter.setServiceTypes(new QNameSet(serviceQname), DPWSCommunicationManager.COMMUNICATION_MANAGER_ID);
SearchManager.searchService(searchParameter, client, null);
System.err.println("End search services ");
System.err.println("End search services");
}
......
package eu.chorevolution.vsb.playgrounds.clientserver.dpwsExample;
package eu.chorevolution.vsb.playgrounds.clientserver.testdpws;
import java.io.IOException;
......@@ -8,6 +8,9 @@ import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.types.QName;
import eu.chorevolution.vsb.playgrounds.clientserver.dpws.DocuExampleDevice;
import eu.chorevolution.vsb.playgrounds.clientserver.dpws.DocuExampleService;
public class DocuExampleServiceProvider {
public static void main(String[] args) {
......
......@@ -98,7 +98,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.9</version>
</dependency>
</dependencies>
</project>
......@@ -91,7 +91,7 @@ public class RestClient {
//// ComplexType Ti = mapper.readValue(serializedObject, ComplexType.class);
// System.out.println(Ti.getstatus());
//
// } catch (JsonMappingException e) {
// } catch (JsonMappingException e){
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
......
......@@ -103,6 +103,14 @@
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>pertest</forkMode>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
......
......@@ -3,7 +3,13 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import eu.chorevolution.vsb.bc.manager.BcManagerRestService;
import eu.chorevolution.vsb.gmdl.utils.PathResolver;
import eu.chorevolution.vsb.gmdl.utils.enums.ProtocolType;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
......@@ -13,43 +19,31 @@ import static org.junit.Assert.*;
public class VsbManagerTest{
public static void main(String[] args) {
String interfaceDescriptionPath = "/home/pntumba/inria_code/doc/bridge.gidl";
generateWarFile(interfaceDescriptionPath);
// generateWarBytes(interfaceDescriptionPath);
}
String interfaceDescriptionPath = null;
public static void generateWarFile(String interfaceDescriptionPath){
@Before
public void setUp(){
VsbManager vsbm = new VsbManager();
vsbm.generateWar(interfaceDescriptionPath, ProtocolType.SOAP);
// vsbm.deleteGeneratedFiles();
interfaceDescriptionPath = PathResolver.myFilePath(BcManagerRestService.class,"bridge.gidl");
}
public static void generateWarBytes(String interfaceDescriptionPath){
byte[] interfaceDescriptionBytesArray = null;
@Test
public void generateWarFile(){
Path path = Paths.get(interfaceDescriptionPath);
try{
boolean generateWarFile = true;
try {
VsbManager vsbm = new VsbManager();
vsbm.generateWar(interfaceDescriptionPath, ProtocolType.SOAP);
vsbm.deleteGeneratedFiles();
interfaceDescriptionBytesArray = Files.readAllBytes(path);
} catch (Exception e){
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
generateWarFile = false;
}
VsbManager vsbm = new VsbManager();
vsbm.generateWar(interfaceDescriptionBytesArray, ProtocolType.SOAP);
// vsbm.deleteGeneratedFiles();
//assertEquals(true, generateWarFile);
}
}
\ 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