summaryrefslogtreecommitdiff
path: root/Year_3/TSDWL/WSDL/BankClient/src
diff options
context:
space:
mode:
Diffstat (limited to 'Year_3/TSDWL/WSDL/BankClient/src')
-rw-r--r--Year_3/TSDWL/WSDL/BankClient/src/conf/MANIFEST.MF2
-rw-r--r--Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.wsdl74
-rw-r--r--Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.xsd_1.xsd52
-rw-r--r--Year_3/TSDWL/WSDL/BankClient/src/java/it/dmi/exam/servlet/BankServlet.java130
4 files changed, 258 insertions, 0 deletions
diff --git a/Year_3/TSDWL/WSDL/BankClient/src/conf/MANIFEST.MF b/Year_3/TSDWL/WSDL/BankClient/src/conf/MANIFEST.MF
new file mode 100644
index 0000000..59499bc
--- /dev/null
+++ b/Year_3/TSDWL/WSDL/BankClient/src/conf/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.wsdl b/Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.wsdl
new file mode 100644
index 0000000..5227e27
--- /dev/null
+++ b/Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.wsdl
@@ -0,0 +1,74 @@
+<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is Metro/2.3.2-b608 (trunk-7979; 2015-01-21T12:50:19+0000) JAXWS-RI/2.2.11-b150120.1832 JAXWS-API/2.2.12 JAXB-RI/2.2.12-b141219.1637 JAXB-API/2.2.13-b141020.1521 svn-revision#unknown. --><!-- Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is Metro/2.3.2-b608 (trunk-7979; 2015-01-21T12:50:19+0000) JAXWS-RI/2.2.11-b150120.1832 JAXWS-API/2.2.12 JAXB-RI/2.2.12-b141219.1637 JAXB-API/2.2.13-b141020.1521 svn-revision#unknown. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://bank.exam.dmi.it/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://bank.exam.dmi.it/" name="BankOperations">
+<types>
+<xsd:schema>
+<xsd:import namespace="http://bank.exam.dmi.it/" schemaLocation="http://localhost:8080/WsBank/BankOperations?xsd=1"/>
+</xsd:schema>
+</types>
+<message name="getAmount">
+<part name="parameters" element="tns:getAmount"/>
+</message>
+<message name="getAmountResponse">
+<part name="parameters" element="tns:getAmountResponse"/>
+</message>
+<message name="deposit">
+<part name="parameters" element="tns:deposit"/>
+</message>
+<message name="depositResponse">
+<part name="parameters" element="tns:depositResponse"/>
+</message>
+<message name="get">
+<part name="parameters" element="tns:get"/>
+</message>
+<message name="getResponse">
+<part name="parameters" element="tns:getResponse"/>
+</message>
+<portType name="BankOperations">
+<operation name="getAmount">
+<input wsam:Action="http://bank.exam.dmi.it/BankOperations/getAmountRequest" message="tns:getAmount"/>
+<output wsam:Action="http://bank.exam.dmi.it/BankOperations/getAmountResponse" message="tns:getAmountResponse"/>
+</operation>
+<operation name="deposit">
+<input wsam:Action="http://bank.exam.dmi.it/BankOperations/depositRequest" message="tns:deposit"/>
+<output wsam:Action="http://bank.exam.dmi.it/BankOperations/depositResponse" message="tns:depositResponse"/>
+</operation>
+<operation name="get">
+<input wsam:Action="http://bank.exam.dmi.it/BankOperations/getRequest" message="tns:get"/>
+<output wsam:Action="http://bank.exam.dmi.it/BankOperations/getResponse" message="tns:getResponse"/>
+</operation>
+</portType>
+<binding name="BankOperationsPortBinding" type="tns:BankOperations">
+<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+<operation name="getAmount">
+<soap:operation soapAction=""/>
+<input>
+<soap:body use="literal"/>
+</input>
+<output>
+<soap:body use="literal"/>
+</output>
+</operation>
+<operation name="deposit">
+<soap:operation soapAction=""/>
+<input>
+<soap:body use="literal"/>
+</input>
+<output>
+<soap:body use="literal"/>
+</output>
+</operation>
+<operation name="get">
+<soap:operation soapAction=""/>
+<input>
+<soap:body use="literal"/>
+</input>
+<output>
+<soap:body use="literal"/>
+</output>
+</operation>
+</binding>
+<service name="BankOperations">
+<port name="BankOperationsPort" binding="tns:BankOperationsPortBinding">
+<soap:address location="http://localhost:8080/WsBank/BankOperations"/>
+</port>
+</service>
+</definitions> \ No newline at end of file
diff --git a/Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.xsd_1.xsd b/Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.xsd_1.xsd
new file mode 100644
index 0000000..cf469e6
--- /dev/null
+++ b/Year_3/TSDWL/WSDL/BankClient/src/conf/xml-resources/web-service-references/BankOperations/wsdl/localhost_8080/WsBank/BankOperations.xsd_1.xsd
@@ -0,0 +1,52 @@
+<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI (http://jax-ws.java.net). RI's version is Metro/2.3.2-b608 (trunk-7979; 2015-01-21T12:50:19+0000) JAXWS-RI/2.2.11-b150120.1832 JAXWS-API/2.2.12 JAXB-RI/2.2.12-b141219.1637 JAXB-API/2.2.13-b141020.1521 svn-revision#unknown. --><xs:schema xmlns:tns="http://bank.exam.dmi.it/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://bank.exam.dmi.it/">
+
+<xs:element name="deposit" type="tns:deposit"/>
+
+<xs:element name="depositResponse" type="tns:depositResponse"/>
+
+<xs:element name="get" type="tns:get"/>
+
+<xs:element name="getAmount" type="tns:getAmount"/>
+
+<xs:element name="getAmountResponse" type="tns:getAmountResponse"/>
+
+<xs:element name="getResponse" type="tns:getResponse"/>
+
+<xs:complexType name="getAmount">
+<xs:sequence/>
+</xs:complexType>
+
+<xs:complexType name="getAmountResponse">
+<xs:sequence>
+<xs:element name="return" type="xs:double"/>
+</xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="deposit">
+<xs:sequence>
+<xs:element name="amount" type="xs:double"/>
+</xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="depositResponse">
+<xs:sequence>
+<xs:element name="return" type="tns:bankOperations" minOccurs="0"/>
+</xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="bankOperations">
+<xs:sequence/>
+</xs:complexType>
+
+<xs:complexType name="get">
+<xs:sequence>
+<xs:element name="amount" type="xs:double"/>
+</xs:sequence>
+</xs:complexType>
+
+<xs:complexType name="getResponse">
+<xs:sequence>
+<xs:element name="return" type="tns:bankOperations" minOccurs="0"/>
+</xs:sequence>
+</xs:complexType>
+</xs:schema> \ No newline at end of file
diff --git a/Year_3/TSDWL/WSDL/BankClient/src/java/it/dmi/exam/servlet/BankServlet.java b/Year_3/TSDWL/WSDL/BankClient/src/java/it/dmi/exam/servlet/BankServlet.java
new file mode 100644
index 0000000..a8a397d
--- /dev/null
+++ b/Year_3/TSDWL/WSDL/BankClient/src/java/it/dmi/exam/servlet/BankServlet.java
@@ -0,0 +1,130 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package it.dmi.exam.servlet;
+
+import it.dmi.exams.client.bank.BankOperations_Type;
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ * @author dcariotti
+ */
+@WebServlet(name = "BankServlet", urlPatterns = {"/BankServlet"})
+public class BankServlet extends HttpServlet {
+
+ /**
+ * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
+ * methods.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ try (PrintWriter out = response.getWriter()) {
+ /* TODO output your page here. You may use following sample code. */
+ out.println("<!DOCTYPE html>");
+ out.println("<html>");
+ out.println("<head>");
+ out.println("<title>Servlet BankServlet</title>");
+ out.println("</head>");
+ out.println("<body>");
+ out.println("<h1>Servlet BankServlet at " + request.getContextPath() + "</h1>");
+ out.println("</body>");
+ out.println("</html>");
+ }
+ }
+
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ double amount = this.getAmount();
+ request.setAttribute("amount", amount);
+ RequestDispatcher view = request.getRequestDispatcher("index.jsp");
+ view.forward(request, response);
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ *
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ double moneyToGet = 0.0;
+ double moneyToDeposit = 0.0;
+
+ String form_deposit = request.getParameter("deposit");
+ String form_get = request.getParameter("get");
+
+ if (form_deposit.length() > 0) {
+ moneyToDeposit = Double.parseDouble(form_deposit);
+ }
+
+ if (form_get.length() > 0) {
+ moneyToGet = Double.parseDouble(form_get);
+ }
+
+ PrintWriter out = response.getWriter();
+
+ out.println("Deposit " + moneyToDeposit + "€");
+ out.println("Get " + moneyToGet + "€");
+
+ this.deposit(moneyToDeposit);
+ this.get(moneyToGet);
+ }
+
+ /**
+ * Returns a short description of the servlet.
+ *
+ * @return a String containing servlet description
+ */
+ @Override
+ public String getServletInfo() {
+ return "Make bank operations";
+ }
+
+ private static BankOperations_Type deposit(double amount) {
+ it.dmi.exams.client.bank.BankOperations_Service service = new it.dmi.exams.client.bank.BankOperations_Service();
+ it.dmi.exams.client.bank.BankOperations port = service.getBankOperationsPort();
+ return port.deposit(amount);
+ }
+
+ private static BankOperations_Type get(double amount) {
+ it.dmi.exams.client.bank.BankOperations_Service service = new it.dmi.exams.client.bank.BankOperations_Service();
+ it.dmi.exams.client.bank.BankOperations port = service.getBankOperationsPort();
+ return port.get(amount);
+ }
+
+ private static double getAmount() {
+ it.dmi.exams.client.bank.BankOperations_Service service = new it.dmi.exams.client.bank.BankOperations_Service();
+ it.dmi.exams.client.bank.BankOperations port = service.getBankOperationsPort();
+ return port.getAmount();
+ }
+
+}