Java JAX-WS Howto

The following guide demonstrates how to use the USAePay-jaxws.jar package with either Sun's Jax-WS 2.1 or Apache Foundation's CXF libary. This package contains a helper class for easily generating security tokens, classes for all USAePay soap objects and a client service class for calling soap methods. The package requires Jax-WS (see Dependencies).


File Version Release Date Description 1.2.0 8/25/09 Library .jar and example .java 1.2.0 9/5/09 USAePay-jaxws-1.2.jar only

Dependencies (Using Apache CXF)

  • USAePay-jaxws-1.2.0.jar
  • apache-cxf-2.2.3/lib/commons-logging-1.1.1.jar
  • apache-cxf-2.2.3/lib/cxf-2.2.3.jar
  • apache-cxf-2.2.3/lib/geronimo-activation_1.1_spec-1.0.2.jar
  • apache-cxf-2.2.3/lib/geronimo-annotation_1.0_spec-1.1.1.jar
  • apache-cxf-2.2.3/lib/geronimo-javamail_1.4_spec-1.6.jar
  • apache-cxf-2.2.3/lib/geronimo-jaxws_2.1_spec-1.0.jar
  • apache-cxf-2.2.3/lib/geronimo-servlet_2.5_spec-1.2.jar
  • apache-cxf-2.2.3/lib/geronimo-stax-api_1.0_spec-1.0.1.jar
  • apache-cxf-2.2.3/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar
  • apache-cxf-2.2.3/lib/jaxb-api-2.1.jar
  • apache-cxf-2.2.3/lib/jaxb-impl-2.1.12.jar
  • apache-cxf-2.2.3/lib/jetty-6.1.19.jar
  • apache-cxf-2.2.3/lib/jetty-util-6.1.19.jar
  • apache-cxf-2.2.3/lib/neethi-2.0.4.jar
  • apache-cxf-2.2.3/lib/saaj-api-1.3.jar
  • apache-cxf-2.2.3/lib/saaj-impl-1.3.2.jar
  • apache-cxf-2.2.3/lib/wsdl4j-1.6.2.jar
  • apache-cxf-2.2.3/lib/wstx-asl-3.2.8.jar
  • apache-cxf-2.2.3/lib/xml-resolver-1.2.jar
  • apache-cxf-2.2.3/lib/XmlSchema-1.4.5.jar

Dependencies (Using Sun's Jax-WS 2.1)

  • USAePay-jaxws-1.2.0.jar
  • jaxb/activation.jar
  • jaxb/api/jaxb-api.jar
  • jaxb/jaxb-impl.jar
  • jaxb/jaxb-xjc.jar
  • jaxb/api/jsr173_api.jar
  • jaxws21/FastInfoset.jar
  • jaxws21/http.jar
  • jaxws21/api/jaxws-api.jar
  • jaxws21/jaxws-rt.jar
  • jaxws21/jaxws-tools.jar
  • jaxws21/api/jsr181-api.jar
  • jaxws21/api/jsr250-api.jar
  • jaxws21/mimepull.jar
  • jaxws21/api/saaj-api.jar
  • jaxws21/saaj-impl.jar
  • jaxws21/sjsxp.jar
  • jaxws21/stax-ex.jar
  • jaxws21/streambuffer.jar

Using Library

Step 1: Import com.usaepay.api.jaxws Classes

In classes that are going to use the USAePay soap methods or object, you need to import the appropriate classes from com.usaepay.api.jaxws package. The following will import all usaepay objects at once:

import com.usaepay.api.jaxws.*;

Step 2: Instantiate client Object

All calls to the USAePay soap servers are handled by a “client” object of type “UeSoapServerPortType”. There are two ways to instantiate the client object. To instantiate a client for use with the main production servers:

// Instantiate client for production
UeSoapServerPortType client = usaepay.getClient();

Alternately, you can specify a server hostname, which will allow you to setup a connection to the sandbox server for testing or a backup datacenter (see the high availability programming guide).

// Instantiate client for sandbox
UeSoapServerPortType client = usaepay.getClient("");

Step 3: Generate Security Token

A “token” object (of type UeSecurityToken) is required by all soap methods in the USAePay API. It is used to identify the merchant.

// Create security token
String SourceKey="YourKeyGoesHere";
String Pin ="YourPinGoesHere";
String ClientIP="";
UeSecurityToken token = usaepay.getToken(SourceKey, Pin, ClientIP);

Step 4: Calling a Soap Method

Soap methods are called using the client object. Below is an example for calling the runSale method. For further examples see the soap api documentation.

TransactionRequestObject request = new TransactionRequestObject();
request.setAccountHolder("Tester John");
TransactionDetail details = new TransactionDetail();
details.setDescription("Example Sale");
CreditCardData ccdata = new CreditCardData();
ccdata.setAvsStreet("1234 Main");
TransactionResponse response;
response = client.runSale(token, request);
System.out.println("Response: " + response.getResult() + " RefNum: " + response.getRefNum());

Additional Documentation

For additional documentation please see the main Soap API Documenation. It includes a description of all methods and their parameters as well as examples for the java library.

For questions please email

developer/soap-1.4/howto/javajaxws.txt · Last modified: 2011/03/25 12:28 by irina

Page Tools