Jaxws client

Run
How to run the sample
The source code for this sample can be found in the javaee7-samples GitHub repository. The first thing we need to do is to get the source by downloading the repository and then go into the samples folder:
git clone git://github.com/javaee-samples/javaee7-samples.git
cd javaee7-samples/jaxws/jaxws-client/
Now we are ready to start testing. You can run all the tests in this sample by executing:
mvn test
Or you can run individual tests by executing one of the following:
mvn test -Dtest=EBookStoreClientSampleTest

  • Specifications in use:

    EBookStoreClientSampleTest

    Missing a description for the story. Add some javadoc to the TestClass. Show me how!

    Method for creating and deploying the war file from jaxws-endpoint project, which contains the web service to be tested.

    @Deployment(testable = false)
    public static WebArchive createDeployment() {
        return ShrinkWrap.create(MavenImporter.class)
                .loadPomFromFile("../jaxws-endpoint/pom.xml")
                .importBuildOutput()
                .as(WebArchive.class);
    }
    Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
    @Test
    public void test1WelcomeMessage() throws MalformedURLException {
        EBookStore eBookStore = eBookStoreService.getEBookStoreImplPort();
        String response=eBookStore.welcomeMessage("Jackson");
        assertEquals("Welcome to EBookStore WebService, Mr/Mrs Jackson", response);
    }
    Missing a description for the test scenario. Add some javadoc to the @Test method. Show me how!
    @Test
    public void test2SaveAndTakeBook() throws MalformedURLException {
        EBookStore eBookStore = eBookStoreService.getPort(EBookStore.class);
    
        EBook eBook=new EBook();
        eBook.setTitle("The Jungle Book");
        eBook.setNumPages(225);
        eBook.setPrice(17.9);
        eBookStore.saveBook(eBook);
        eBook=new EBook();
    
        eBook.setTitle("Animal Farm");
        eBook.setNumPages(113);
        eBook.setPrice(22.5);
        List<String> notes= Arrays.asList(new String[]{"Great book","Not too bad"});
        eBook.getNotes().addAll(notes);
        eBookStore.saveBook(eBook);
    
        EBook response=eBookStore.takeBook("Animal Farm");
        assertEquals(eBook.getNumPages(),response.getNumPages());
        assertEquals(eBook.getPrice(),response.getPrice(),0);
        assertEquals(eBook.getTitle(),response.getTitle());
        assertEquals(notes,response.getNotes());
    
    }

    Share the Knowledge

    Find this sample useful? Share on

    There's a lot more about JavaEE to cover. If you're ready to learn more, check out the other available samples.

    Help Improve

    Find a bug in the sample? Something missing? You can fix it by editing the source, making the correction and sending a pull request. Or report the problem to the issue tracker

    Recent Changelog

    • Feb 10, 2014: Removed unnecessary files in jax-ws projects by Fermin Gallego
    • Feb 07, 2014: Added jax-ws client example by Fermin Gallego
    How to help improve this sample
    The source code for this sample can be found in the javaee7-samples GitHub repository. The first thing you need to do is to get the source by downloading the repository and then go into the samples folder:
    git clone git://github.com/javaee-samples/javaee7-samples.git
    cd javaee7-samples/jaxws/jaxws-client/

    Do the changes as you see fit and send a pull request!

    Good Luck!