Restructure: Client uses wsimport instead of MoviesCommon

This commit is contained in:
karl 2019-12-02 10:30:38 +01:00
parent 28a73932ae
commit 997a167c2e
8 changed files with 55 additions and 25 deletions

6
.idea/compiler.xml generated
View File

@ -13,9 +13,9 @@
</annotationProcessing>
<bytecodeTargetLevel>
<module name="MoviesApp" target="11" />
<module name="MoviesClient" target="11" />
<module name="MoviesCommon" target="11" />
<module name="MoviesWebApp" target="11" />
<module name="MoviesClient" target="9" />
<module name="MoviesCommon" target="9" />
<module name="MoviesWebApp" target="9" />
</bytecodeTargetLevel>
</component>
</project>

View File

@ -15,6 +15,7 @@
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/target/generated" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
@ -58,6 +59,5 @@
<orderEntry type="library" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.2" level="project" />
<orderEntry type="library" name="Maven: jakarta.xml.soap:jakarta.xml.soap-api:1.4.1" level="project" />
<orderEntry type="library" name="Maven: jakarta.jws:jakarta.jws-api:1.1.1" level="project" />
<orderEntry type="module" module-name="MoviesCommon" />
</component>
</module>

View File

@ -24,12 +24,6 @@
<artifactId>jaxws-ri</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>at.technikumwien</groupId>
<artifactId>MoviesCommon</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
@ -68,6 +62,25 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.helger.maven</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.6.2</version>
<configuration>
<wsdlUrls>
<wsdlUrl>http://localhost:8080/movieservice/MoviesWebService?wsdl</wsdlUrl>
</wsdlUrls>
<packageName>at.technikumwien.movies.generated</packageName>
<sourceDestDir>${project.build.directory}/generated</sourceDestDir>
</configuration>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>

View File

@ -0,0 +1,23 @@
package at.technikumwien.movies;
import at.technikumwien.movies.generated.Movie;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
/** Wrapper for XML with multiple movies **/
@XmlRootElement(name = "movies")
public class MovieList {
@XmlElement(name="movie")
public List<Movie> movies;
public MovieList(List<Movie> movies) {
this.movies = movies;
}
public MovieList() {
this.movies = new ArrayList<Movie>();
};
}

View File

@ -1,17 +1,16 @@
package at.technikumwien.movies;
import javax.xml.namespace.QName;
import at.technikumwien.movies.generated.Movie;
import at.technikumwien.movies.generated.MoviesWebService_Service;
import javax.xml.ws.Service;
import java.net.URL;
import java.util.List;
public class MoviesWebServiceClient {
public static void main(String[] args) throws Exception {
URL wsdl = new URL("http://localhost:8080/movieservice/MoviesWebService?wsdl");
QName serviceName = new QName("http://movies.technikumwien.at/", "MoviesWebService");
Service service = Service.create(wsdl, serviceName);
MoviesWebService port = service.getPort(MoviesWebService.class);
MoviesWebService_Service service = new MoviesWebService_Service();
at.technikumwien.movies.generated.MoviesWebService port = service.getMoviesWebServicePort();
// TODO: Move to a better place

View File

@ -6,7 +6,7 @@ import java.io.File;
import java.util.List;
public class XmlHelper {
public static void moviesToXml(List<Movie> movies, String filename) throws Exception {
public static void moviesToXml(List<at.technikumwien.movies.generated.Movie> movies, String filename) throws Exception {
MovieList movieList = new MovieList(movies);
JAXBContext jaxbContext = JAXBContext.newInstance(MovieList.class);
@ -20,7 +20,7 @@ public class XmlHelper {
marshaller.marshal(movieList, new File(filename));
}
public static List<Movie> xmlToMovies(String filename) throws JAXBException {
public static List<at.technikumwien.movies.generated.Movie> xmlToMovies(String filename) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(MovieList.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

View File

@ -1,16 +1,11 @@
package at.technikumwien.movies;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/** Wrapper for XML with multiple movies **/
@XmlRootElement(name = "movies")
@AllArgsConstructor
@NoArgsConstructor
public class MovieList {
@XmlElement(name="movie")
public List<Movie> movies;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<movies>
<movie title="Test Movie VII" description="Same as Test Movie IV" genre="COMEDY" length="119" releaseyear="2022">
<movie title="Test Movie VIII" description="Weird" genre="COMEDY" length="119" releaseyear="2022">
<actors>
<actor firstname="Test" lastname="Actor" sex="MALE" birthdate="01.01.1888"/>
</actors>