This document contains conceptual and procedural information on connecting your development environment or other systems to the ExactTarget web service API using Java via the Axis2 SOAP client. Axis2 is a SOAP client preferred by many Java users.
You can use the connection to the web service API to test your calls and perform various tasks, such as sending email and retrieving tracking information.
Download Apache Axis2 at http://ws.apache.org/axis2 and follow the appropriate instructions at that site to install the service on your computer. You can use the sample code below to authenticate your installation and exchange information with the web service API servers.
The sample code below demonstrates how to connect and interact with the web service API.
This sample code demonstrates how to use Java and Axis2 to authenticate with the web service API.
public class PWCBHandler implements CallbackHandler {
public static String user = ClientTest.getProperties().getProperty("user");
public static String password = ClientTest.getProperties().getProperty("password");
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
String id = pwcb.getIdentifer();
if(user.equals(id)) {
pwcb.setPassword(password);
}
}
} //end method handle
} //end class PWCBHandler
String endpoint = properties.getProperty( "endpoint" ); //Create reference to ExactTarget Web Service API. EndpointReference endPointReference = new EndpointReference( endpoint ); //Create Axis2 ConfigurationContext; an Axis2 ConfigurationContext is like an in-memory database that holds static //and dynamic data. Note that at the client side we have no services, so the concept of a repository is not that useful. ConfigurationContext configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem( repositoryLocation, configurationFileLocation ); //Create PartnerAPIStub with ExactTarget Web Service API endpoint and Axis2 ConfigurationContext. PartnerAPIStub stub = new PartnerAPIStub( configurationContext, endpoint ); //Create Axis2 ServiceClient from PartnerAPIStub. An Axis2 ServiceClient provides an easy way to invoke services. ServiceClient serviceClient = stub._getServiceClient(); //Create security options. Remaining security setup is within axis2-client.xml; while there exist programmatic //methods of setting up Rampart and OutflowSecurity, the XML methods are preferred. Options options = new Options(); options.setTo( endPointReference ); serviceClient.setOptions( options );
<axisconfig name="AxisJava2.0">
<module ref="rampart" />
<parameter name="OutflowSecurity">
<action>
<items>UsernameToken</items>
<user>et_documentation</user>
<passwordCallbackClass>com.exacttarget.samples.Axis2v12.client.PWCBHandler</passwordCallbackClass>
<passwordType>PasswordText</passwordType>
</action>
</parameter>
.... </axisconfig>
Use the information below to round out your knowledge of using Java with the web service API.
Examples for C# and Java
http://www.adobe.com/devnet/livecycle/articles/passing_credentials.html
| File | Size | Date | Attached by | |||
|---|---|---|---|---|---|---|
| AxisSampleProject.zip No description | 9.81 MB | 18:17, 20 Apr 2010 | Admin | Actions | ||