Getting started

This project is designed to encapsulate the API provided by the EMS Web Services to make using the api with java much easier. The project is implemented using Spring Web Services 2.2.x (and Spring 4). Learn more about Spring at http://projects.spring.io/spring-framework.

Maven

You will need to add the CAE EMS API Maven Repository to your pom.xml file

      <repositories>
        <repository>
            <id>code.ems-public-releases</id>
            <url>https://emsapi.cae.wisc.edu/maven/content/repositories/public-releases/</url>
        </repository>
      </repositories>

and a dependency on the client library (see the shared Maven repository for current version numbers):

     <dependency>
         <groupId>edu.wisc.cae</groupId>
         <artifactId>emsclient</artifactId>
         <version>1.0-SNAPSHOT</version>
     </dependency>

Usage

The quickest way to get started using the client is to define a bean in your application similar to:

    <!-- the ems client bean -->
    <bean id="emsClient" class="edu.wisc.cae.emsclient.EmsClient">
        <constructor-arg name="login" value="${emsclient.username}" />
        <constructor-arg name="password" value="${emsclient.password}" />
        <constructor-arg ref="webServiceTemplateEms"/>
    </bean>

    <!-- used by the ems client bean -->
    <bean id="messageFactoryEms" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
        <property name="soapVersion" value="SOAP_12"/>
    </bean>

    <bean id="webServiceTemplateEms" class="org.springframework.ws.client.core.WebServiceTemplate">
        <constructor-arg ref="messageFactoryEms"/>
        <property name="marshaller" ref="marshaller" />
        <property name="unmarshaller" ref="marshaller" />
        <property name="destinationProvider">
            <bean class="org.springframework.ws.client.support.destination.Wsdl11DestinationProvider">
                <property name="wsdl" value="${emsclient.wsdl}" />
            </bean>
        </property>
        <property name="interceptors">
            <bean class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
                <property name="secureRequest" value="false" />
                <property name="secureResponse" value="false" />
                <property name="validateRequest" value="false" />
                <property name="validateResponse" value="false" />
                <property name="validationActions" value="NoSecurity" />
            </bean>
        </property>
        <property name="messageSender">
            <bean class="org.springframework.ws.transport.http.HttpComponentsMessageSender"/>
        </property>
    </bean>

    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="contextPaths">
            <list>
                <value>edu.wisc.cae.emsclient.ws</value>
                <value>edu.wisc.cae.emsclient.model</value>
            </list>
        </property>
    </bean>

When using the above example, you will also need to create a properties file to provide the values of the emsclient username and password. These will be used at runtime to connect to the EMS API

Next, in your java code, you can create a java objected simply by instantiating the bean. An example is

       ApplicationContext context = new ClassPathXmlApplicationContext("spring/app-context.xml");

       // Create EMS Client
       emsClient = (EmsClient)context.getBean("emsClient");

You can then call the functions of the client in your code. When you do, the client will contact the EMS Client and perform the operation specified.