Add sample SOAP web service
authorCarlos Aristu <carlos.aristu@openbravo.com>
Wed, 17 Apr 2019 14:11:49 +0200
changeset 41 3b4d0985e381
parent 40 c5004c7571f6
child 42 962fb5f7a4ca
Add sample SOAP web service
src/org/openbravo/platform/features/service/soap/Calculator.java
src/org/openbravo/platform/features/service/soap/CalculatorImpl.java
src/org/openbravo/platform/features/service/soap/SampleSOAPWebServiceRegister.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/platform/features/service/soap/Calculator.java	Wed Apr 17 14:11:49 2019 +0200
@@ -0,0 +1,38 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2019 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.platform.features.service.soap;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+/**
+ * This class is a service endpoint interface (SEI). It is the piece of Java code that is shared
+ * between a service and the consumers that make requests on it. The methods defined in this class
+ * are intended to be mapped to the operations exposed by the service.
+ */
+@WebService
+public interface Calculator {
+
+  @WebMethod
+  public int sum(int val1, int val2);
+
+  @WebMethod
+  public int multiply(int val1, int val2);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/platform/features/service/soap/CalculatorImpl.java	Wed Apr 17 14:11:49 2019 +0200
@@ -0,0 +1,27 @@
+package org.openbravo.platform.features.service.soap;
+
+import javax.jws.WebService;
+
+import org.openbravo.base.provider.OBSingleton;
+
+/**
+ * This class is the service implementation of the {@link Calculator} class.
+ */
+@WebService(endpointInterface = "org.openbravo.platform.features.service.soap.Calculator", portName = "calculator", serviceName = "calculator")
+public class CalculatorImpl implements Calculator, OBSingleton {
+
+  public CalculatorImpl() {
+    System.out.println("-----> New instance");
+  }
+
+  @Override
+  public int sum(int val1, int val2) {
+    return val1 + val2;
+  }
+
+  @Override
+  public int multiply(int val1, int val2) {
+
+    return val1 * val2;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/platform/features/service/soap/SampleSOAPWebServiceRegister.java	Wed Apr 17 14:11:49 2019 +0200
@@ -0,0 +1,38 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html 
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2019 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.platform.features.service.soap;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openbravo.base.cxf.SOAPWebServiceRegister;
+import org.openbravo.base.provider.OBSingleton;
+
+/**
+ * Registers the {@link Calculator} sample SOAP web service.
+ */
+public class SampleSOAPWebServiceRegister implements SOAPWebServiceRegister {
+
+  @Override
+  public Map<String, Class<? extends OBSingleton>> getSOAPWebServices() {
+    Map<String, Class<? extends OBSingleton>> services = new HashMap<>();
+    services.put("calculator", CalculatorImpl.class);
+    return services;
+  }
+}