mvn archetype:generate -DgroupId=com.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false
Replace "my-app" in DartifactId with your project name
- Click on "New Project" on the Project tab
- Enter the name and path directory where you want your project
- Select Java as the language and Maven as the build system
- Press shift + command + p, and type in Maven: New Project
- Select any archetype and version
- For the artifact Id, enter your project name
- Navigate to where you want to place your project
- Copy the server side code from web_service_server_code directory to <your_project_name>/src/main/java
- Add the jaxws-ri dependency into the pom.xml file
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.3</version>
<type>pom</type>
</dependency>
</dependencies>
- Run the HelloWorldPublisher.java
- Go to http://localhost:7779/ws/hello and download the WSDL file
- Download the wsimport tool from https://repo1.maven.org/maven2/com/sun/xml/ws/jaxws-ri/4.0.0/jaxws-ri-4.0.0.zip
- Navigate to jaxws-ri/bin, where the wsimport.sh is located
- Run the following command for extracting seng4400 folder from the downloaded wsdl file
./wsimport.sh hello.wsdl -keep
alternatively, if the wsdl file has not been downloaded, replace "hello.wsdl" with "http://localhost:7779/ws/hello?wsdl"
- This should create a new folder "seng4400", with stub code
- Create a new client maven project
- Add the jaxws-ri dependency
- Move the seng4400 folder into client/src/main/java
- Create a new class with the following in the main method
HelloWorldImplService service = new HelloWorldImplService();
HelloWorld helloWorldObj = service.getHelloWorldImplPort();
String result = helloWorldObj.getHelloWorld();
System.out.println(result);
- Run the newly created class (Note: if you get errors; try using a recent, 4.0.3, version of jaxws and/or replacing jakarta with javax in the stub code). If successful, "Hello World" should be printed on the client terminal.
- On the server side, add a parameter (such as String name) to the getHelloWorld() method
- Re-compile and re-run the server, and execute the client; should see that either null is printed in place of your parameter or you will get a SOAP fault from the server (if you download a new copy of the wsdl file, you should see that the getHelloWorld function is followed by your new parameter and variable type)
- Complete task 5