Scanning Sample Web Services Client
Overview
The following Java based EIP Web Services client code is available as an example of how to work with EIP Web Services for the Scanning application.
The intent of this sample is to illustrate a working client from which to base an integration project.
As with all examples this code is for illustration purposes only and not for production usage.
Requirements
Must have the following Java versions and tools to work with this sample:
- Java 6.0 and above
- Maven 3
Working Knowledge
- Spring and Spring Web Services
- Java and Spring Annotations
- JUnit
- Maven and Maven Plugins: jaxws-maven-plugin, maven-jar-plugin, maven-source-plugin, maven-surefire-plugin
Projects
We have split the sample into 2 projects:
Project
|
Description
|
---|---|
eip-wsdl-import |
Creates the Web Service Java Proxy classes representing the Outgoing and Incoming EIP Web Service artifacts. Must build/install prior to running the eip-client. |
eip-client |
Contains the infrastructure necessary to communicate with the EIP services. Additionally within the Unit Testing classes there is a Scanning class containing examples of the basic scanning operations. |
eip-wsdl-import usage
Please click here to download the project.
Once the project has been downloaded please run the following maven command from within the folder containing the pom.xml
> mvn install
This will generate, package and install the classes required for communicating with the EIP web services API.
Under the target directory there should be 2 jars (eip-wsld-import-0.0.1-SNAPSHOT.jar and eip-wsld-import-0.0.1-SNAPSHOT-sources.jar) containing the classes and the sources derived from the EIP services.
Under the src directory there should be java files:
The pom.xml
|
The wsdlUrls in the configuration points to the services.
eip-client usage
Please click here to download the project.
The project structure is as follows:
The src directory contains some basic services that enable to communication to the EIP services.
Below are some of the methods in the Services.java class that represent the main EIP API calls.
|
The test directory contains a unit test class for scanning that encapsulates a few of the basic calls needed to interact with the scanning application.
Below is one of the sample test cases in the ScanningTest.java file. Though these are not truly unit test we have encapsulated the calls within test methods to call attention that these are not intended to be used for production quality.
As you can see the context configurations are wired in via a annotation func-test-context.xml and web-service-test-context.xml additionally the Services api described above is wired in as a resource. We can then setup the scanning specific calls. In this case we are demonstrating how to look up available count of scanned messages based on their read state.
|
The resources directory in the test directory contains the spring based contexts required to wire the EIP services.
The web-service-test-context.xml configures the web services by first deonoting the marshaller class, then the security interceptor for handling login to the services and finally the messaging templates that bring it all together. The eipOutMsgTemplate and the eipInMsgTemplate are wired into the Services object to do the actual web service calls.
|
The above references: eip.outgoing.url and the eip.incoming.url are specified in the dev.properties file.
|
The func-test-context.xml allows us to wire in the dev.properties file and also wire in the Services with the spring based web service messaging templates
|
The securityPolicyClient.xml contains the credentials for the web service calls
|
The following code highlights how to pull scan messages from EIP.
|
Run the following maven command from within the folder containing the pom.xml
> mvn test
This will build and run the test classes against the live EIP services.