Web Services in Java

(przepraszam za miks językowy / sorry for language mix)

References for subject 7

Official:

Preparation

  1. SoapUI

    • Download a version for your system from this site and unpack or install
    • If you're working on a lab computer, you can unzip Linux installation package directly from my account

      tar xfzv ~czarnik/xml/soapui-4.6.0-linux-bin.tar.gz

  2. JBoss

    • From JBoss download site download and unpack JBoss AS 7.1.1.Final
    • If you're working on a lab computer, you can unzip Linux installation package directly from my account

      unzip ~czarnik/xml/jboss-as-7.1.1.Final.zip

  3. Unpack XML07-WS.zip – this is a whole Eclipse workspace, not a single project.
  4. Eclipse

    1. Have Eclipse Kepler for Java EE Developers (it is available on lab comps when you type eclipse).
    2. Use the above unpacked workspace folder.
    3. Go to Help > Market Place, type e.g. JBoss Kepler and install the appropriate JBoss Tools plugin. From the list of packages select only JBoss Webservices Tools and JBossAS Tools.
    4. After a restart go to Servers tab (visible in Java EE perspective) and add the JBoss server. Start the server and check http://localhost:8080 address in a Web browser.

Client side

Task 1.

Use Soap UI to connect to remote services:

  1. Cdyne Weather (copy WSDL address, in Soap UI add new SOAP project and paste the copied address to the second field). Check the current weather in the city identified with ZIP 10101.
  2. Global Weather (WSDL)

Note the differences between formats of the responses. Find relevant differences in WSDLs. Which approach is better?

Task 2. SAAJ client

Project Client_Weather_SAAJ contains a client of Cdyne Weather service which uses SAAJ library.

  1. Run the program.
  2. Add some code which finds and prints the current wind (or whatever).

Task 3. JAX-WS client

Project Client_Weather_JAXWS contains a client of Cdyne Weather service which uses high-level JAX-WS (proxy object).

  1. Run the program.
  2. Print more information (wind, humidity, or whatever).

Server side by JAX-WS

Bottom-up

Task 4.

Projekt Server_Hello zawiera prostą usługę z operacjami: sayHello i getPerson.

  1. Uruchom na serwerze (np. Add and Remove).
  2. Połącz się z usługą za pomocą SoapUI i przetestuj obie operacje
  3. Zauważ różnice między metodami sayHello i sayHello2 i w komunikatach SOAP.
  4. Za pomocą adnotacji @XmlElement i @XmlAttribute w klasach Person i Address zmień nazwy elementów (np. first-name zamiast firstName), a płeć przesyłaj jako atrybut. Odśwież projekt na serwerze i przetestuj ponownie.

Top-down

Przykład Kalkulator na trzy sposoby. Projekty Kalkulator... zawierają gotowe WSDL-e i pozwalają spróbować generowania kodu Javy na ich podstawie.

Task 5.

Dla każdej wersji Kalkulatora - RPC, DocumentBare i DocumentWrapped:

  1. Wygeneruj klasy Javy poleceniem Eclipse'a (jeśli masz wtyczkę JBossTools) Generate Java Bean Skeleton. Uwaga! Na ekranie dialogowym, który się pojawi, opuść suwak do pozycji "Develop service" oraz wybierz implementację Web Serwisów "JBossWS" (a nie Axis!).
  2. Alternatywnie można użyć polecenia command line wsconsume (z JBossa) albo wsimport (z Javy).
  3. Uzupełnij implementację.
  4. Wdróż usługę na serwer (np. Server > Add and Remove) i przetestuj za pomocą SoapUI.

Low level service implementation

Można uruchmić projekty na serwerze.


Valid XHTML 1.1Valid CSS