Java JAX-WS Howto
The following guide demonstrates how to use the Newtek GatewayResApi-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 Newtek Gateway objects and a client service class for calling web service methods. The package requires Jax-WS (see Dependencies).
Downloads
File | Version | Release Date | Description |
---|---|---|---|
newtekresapi-jaxws-1.4.0.zip | 1.4.0 | 10/07/10 | Library .jar and example .java |
newtekresapi-jaxws-1.4.0.zip | 1.4.0 | 10/07/10 | Newtek GatewayResAPI-jaxws-1.4.jar only |
Dependencies (Using Apache CXF)
- Newtek GatewayResAPI-jaxws-1.4.jar
- apache-cxf-2.2.9/lib/commons-logging-1.1.1.jar
- apache-cxf-2.2.9/lib/cxf-2.2.9.jar
- apache-cxf-2.2.9/lib/geronimo-activation_1.1_spec-1.0.2.jar
- apache-cxf-2.2.9/lib/geronimo-annotation_1.0_spec-1.1.1.jar
- apache-cxf-2.2.9/lib/geronimo-javamail_1.4_spec-1.6.jar
- apache-cxf-2.2.9/lib/geronimo-jaxws_2.1_spec-1.0.jar
- apache-cxf-2.2.9/lib/geronimo-servlet_2.5_spec-1.2.jar
- apache-cxf-2.2.9/lib/geronimo-stax-api_1.0_spec-1.0.1.jar
- apache-cxf-2.2.9/lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar
- apache-cxf-2.2.9/lib/jaxb-api-2.1.jar
- apache-cxf-2.2.9/lib/jaxb-impl-2.1.12.jar
- apache-cxf-2.2.9/lib/jetty-6.1.19.jar
- apache-cxf-2.2.9/lib/jetty-util-6.1.19.jar
- apache-cxf-2.2.9/lib/neethi-2.0.4.jar
- apache-cxf-2.2.9/lib/saaj-api-1.3.jar
- apache-cxf-2.2.9/lib/saaj-impl-1.3.2.jar
- apache-cxf-2.2.9/lib/wsdl4j-1.6.2.jar
- apache-cxf-2.2.9/lib/wstx-asl-3.2.8.jar
- apache-cxf-2.2.9/lib/xml-resolver-1.2.jar
- apache-cxf-2.2.9/lib/XmlSchema-1.4.5.jar
Dependencies (Using Sun's Jax-WS 2.1)
- Newtek Gateway-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: Importcom.newtek.resapi.jaxws Classes
In classes that are going to use the Newtek Gateway methods or object, you need to import the appropriate classes from com.newtek.resapi.jaxws package. The following will import all newtek objects at once:
import com.newtek.resapi.jaxws.*;
Step 2: Instantiate client Object
All calls to the Newtek Gateway web service 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 = newtek.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 = newtek.getClient("sandbox.newtekgateway.com");
Step 3: Generate Security Token
A "restoken" object (of type UeSecurityToken) is required by all methods in the Newtek Gateway Reseller API. It is used to identify and authenticate the reseller.
// Create security token
String SourceKey="YourKeyGoesHere";
String Pin ="YourPinGoesHere";
String ClientIP="10.10.10.10";
UeSecurityToken restoken = newtek.getToken(SourceKey, Pin, ClientIP);
Step 4: Calling a Webservice Method
Web service methods are called using the client object. Below is an example for calling the getMerchant method. For further examples see the api documentation.
// Set the merchant ref num (merchid)
BigInteger merchrefnum = new BigInteger("118227");
// Create response object
Merchant merch;
// Retrieve Merchant
merch = client.getMerchant(restoken, merchrefnum);
// Display response
System.out.println("Merchant: " + merch.getMerchantName());
Additional Documentation
For addition documentation on which methods are available and example usage, please see the main Reseller API Documenation. The documentation includes a description of all methods and their parameters as well as examples for the java library.
If you run into any trouble please contact our integration support department.