Version 4

    The JBossWS binary distribution comes with a samples testsuite covering the most important JAX-WS features. The samples allow user to practise with JAX-WS starting from small working applications. They can be deployed and run against any supported integration target and stack.

    Users should be aware of samples that are shipped with the distribution since they can help them a lot both in getting started and understanding the most advanced JAX-WS features.

    Running the samples

    To run the samples testsuite you need to have a properly installed JBossWS. Then simply run the tests through Ant:

    cd jbossws-native-3.1.0.GA
    ant
    

    This will build the samples and create their archives in the output/libs directory. Each sample usually has jar and war archives for client and server sides.

    ant tests-samples
    

    This will run the samples subset of the complete JBossWS testsuite. Make sure the AS is running before starting with the tests. The JBossWS test system will loop on the samples' collection:

    1. The server side archive is hot deployed on the configured JBoss application server.
    2. The client side test case is performed (this of course involves invoking the server endpoint).
    3. The server side archive is undeployed.

    Please note that in order to run the tests you need JUnit libraries in your classpath. This can be achieved in different ways; refer to the installation page or simply put the JUnit jar in your current Ant installation's lib directory.

    Finally, if you want to easily run the samples testsuite from your IDE, please read here how to configure it.

     

    Available samples

    Even if you can get an idea of each sample contents from the package name before looking at the code, a short description of the sample aims and covered technologies is provided below. A brief description of the sample's scenario is also provided whenever it makes sense.

    In order to better understand the samples, you might take a look at the archives in the output/libs directory. Examine the archives' contents of the sample you're playing with and check which classes and descriptors are required on each side.

    org.jboss.test.ws.jaxws.samples.asynchronous

    This sample shows different means  of performing client asynchronous invocations. A simple echo operation is called, then the response is verified against the expected one. Timeouts allow the client to stop waiting for the response whenever the process takes too much time. Invocation examples are provided using both the dispatch and dynamic proxy approach.

    org.jboss.test.ws.jaxws.samples.context

    This sample aims at showing how to configure web context parameters. A web service with a given context root and requiring http basic authentication is exposed through EJB3 and POJO endpoints. Security domain and allowed roles are also specified.

    org.jboss.test.ws.jaxws.samples.exception

    A web service endpoint throwing runtime, soap fault and application exceptions is invoked. Responses are verified checking whether messages contain the expected error details.

    org.jboss.test.ws.jaxws.samples.handlerchain

    This sample shows how to use handlers both on client and server side. Four handlers apply modifications to the soap body and header as well as to the mime headers. The test case invokes the web service endpoint and verifies that the result message is the expected one, i.e. all the handlers did their work in the right order. The test is performed both with a pre-defined client handler chain and a collection of handlers programmatically added to the binding provider.

    org.jboss.test.ws.jaxws.samples.httpbinding

    This sample is almost the same as org.jboss.test.ws.jaxws.samples.provider except they use HTTPBinding.HTTP_BINDING binding type, i.e. simple xml messages go to the wire instead of SOAP messages.

    org.jboss.test.ws.jaxws.samples.logicalhandler

    Extensive test of logical handlers. This works the same way as the org.jboss.test.ws.jaxws.samples.handlerchain but it only has logical handlers modifying the soap message obtained from the message context.

    org.jboss.test.ws.jaxws.samples.oneway

    A simple web service endpoint exposing a oneway method is invoked using a Dispatch.

    org.jboss.test.ws.jaxws.samples.provider

    This sample's aim is to show the use of the endpoint provider approach. Two service endpoints work at message level dealing with entire SOAP requests/responses (Service.Mode.MESSAGE) obtained from JAXB marshalling of a given user type or directly from a text string. Another endpoint performs changes on the payload only. A logical handler is also configured to show how handlers can be used with provider/dispatch too.

    org.jboss.test.ws.jaxws.samples.retail

    An order management service is provided; it leverages credit card verification and profile management services to verify billing details and eventual customer discounts. The client send orders to the server that processes them and replies with their status. This sample uses most of the basic JAX-WS features as well as web service references and handlers.

    org.jboss.test.ws.jaxws.samples.securityDomain

    This sample shows how to setup the security domain using the @SecurityDomain annotation available in the different target containers.

    org.jboss.test.ws.jaxws.samples.soapbinding

    This sample's test case invokes three web service endpoint using different soap bindings: rpc/literal, document/literal bare, document/literal wrapped. Invocations are performed both through dynamic proxy and dispatch.

    org.jboss.test.ws.jaxws.samples.swaref

    This sample shows how to deal with attachments using SwaRef. Three endpoints with different soap binding styles have operations accepting and returning attachments through DataHandlers annotated with @XmlAttachmentRef.

    org.jboss.test.ws.jaxws.samples.webmethod

    This demonstrates the use of @WebMethod annotation. The test case performs legal and illegal invocations to an endpoint both using a dynamic proxy and a dispatch.

    org.jboss.test.ws.jaxws.samples.webparam

    This demonstrates the use of @WebParam annotation. The test case invokes an endpoint having operations with different kinds of parameters including INOUT and header.

    org.jboss.test.ws.jaxws.samples.webresult

    This demonstrates the use of @WebResult annotation. A test web service endpoint provides customer's record given customer's name and address. The test case invokes the endpoint and verifies the result matches the expected customer's record.

    org.jboss.test.ws.jaxws.samples.webservice

    This sample shows how to use the @WebService annotation. EJB3 and POJO endpoints both with generated and user-defined wsdl contracts receive invocations by the test case client.

    org.jboss.test.ws.jaxws.samples.webserviceref

    This sample shows different ways of using the @WebServiceRef annotation. Multiple and single references both to Service classes and SEIs are used in EJB3, servlet and plain java class clients.

    org.jboss.test.ws.jaxws.samples.xop

    This sample shows how to use MTOM/XOP. MTOM is enabled through the @BindingType annotation both on a wrapped and a bare parameter style endpoints. Two test cases invoke echo operations on those endpoints both using binary-optimized requests and requests with inlined representation of the binary data.