Existing implementations using WSDL directly
This information pertains if you are upgrading to Unica Campaign version 8.6 or higher and you currently use the WSDL to interact with the Unica Campaign web application. The WSDL of the Unica Campaign web service is used to generate client-side stubs and supporting classes by using any third-party converter tool. Examples provided here use the WSDL2Java tool from Apache AXIS2 1.5.2.
WSDL location and service URL
The Unica Campaign web service for Unica Campaign is deployed at:
http://host:port/Campaign/services/CampaignServices30Service
The corresponding WSDL can be retrieved at:
http://host:port/Campaign/services/CampaignServices30Service?wsdl
Generating stubs and classes
The WSDL2Java tool from Apache AXIS2 1.5.2 can be used to generate the stubs and supporting Java™ classes from the WSDL. A sample Ant task is shown here.
The tool can also be used from the command line with the similar set of arguments. The argument values can be modified to suit to your environment.
<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
<classpath refid="axis2.class.path"/> <!-Class path having
AXIS2 libraries -->
<arg value="-uri"/>
<arg file="CampaignServices30.wsdl"/> <!-Actual location of
WSDL -->
<arg value="-s"/> <!-- Generate sync style code -->
<arg value="-Euwc"/> <!-- Takes care of generating Wrapper
java types for nillable = true elements. -->
<arg value="-uw"/> <!-- Unwrap params -->
<arg value="-u"/> <!-- Unpack classes -->
<arg value="-ns2p"/> <!-- Namespace to package mapping. Customer
can have their own package names. -->
<arg value="http://webservices.unica.com/campaign/CampaignServices/
3.0=com.unica.publicapi.campaign.campaignservices.soap.v30"/>
<arg value="-o"/> <!-- Output directory -->
<arg file="${autogen.java.dir}"/>
</java>
Using generated stubs and supporting classes
The stub can be used as follows:
CampaignServices30ServiceStub serviceStub = new
CampaignServices30ServiceStub(serviceURL);
serviceStub._getServiceClient().getOptions().setTimeOutInMilliSeconds
(webServiceTimeout); //Timeout in milliseconds.
The offer can be created as follows:
try{
//Please change host and port to match your environment.
String serviceURL = "http://host:port/Campaign/services/CampaignServices30Service";
CampaignServices30ServiceStub serviceStub = new CampaignServices30ServiceStub(serviceURL);
long webServiceTimeout = 2*60*1000; // 2 minutes
serviceStub._getServiceClient().getOptions().setTimeOutInMilliSeconds(webServiceTimeout); //Timeout in milliseconds.
WSTextAttribute nameAttirbute = new WSTextAttribute();
nameAttirbute.setMetadata(null);
nameAttirbute.setName("uacOfferDescription");
nameAttirbute.setValues(new String[]{"description " + System.currentTimeMillis()});
WSTextAttribute[] wsAttributes = {nameAttirbute};
// convert to WSAttributeArrays
WSAttributeArrays obj = new WSAttributeArrays();
obj.setTextAttributes(wsAttributes);
//Please change the values of following variables to match your environment.
String authorizationLoginName = "asm_admin"; //login user name
String partitionName = "partition1"; //Use your security policy of Campaign
String securityPolicyName = "Global Policy"; //Use your security policy of Campaign
String offerName = "1st Offer"; //Name of the offer to be created.
String templateName = "Offer Template"; //Existing offer template name.
long folderID = 100; //Actual ID of the folder where this offer will be created.
//For folderID <=0, offer will be created at root level.
CreateOffer createOfferObject = new CreateOffer();
createOfferObject.setAuthorizationLoginName(authorizationLoginName);
createOfferObject.setPartitionName(partitionName);
createOfferObject.setRequestedLocale(Locale.US.toString());
createOfferObject.setSecurityPolicyName(securityPolicyName);
createOfferObject.setName(offerName);
createOfferObject.setFolderID(folderID);
createOfferObject.setTemplateName(templateName);
createOfferObject.setAttributes(obj);
// make campaign WebService call
WSCreateOfferResponse wsResponse = serviceStub.createOffer(createOfferObject);
// process status
WSRequestStatus status = wsResponse.getStatus();
// done
WSOfferInfo offerInfo = wsResponse.getOfferInfo();
System.out.println("status = "+status.getStatusType());
System.out.println("offerInfo = "+offerInfo.getName());
} catch (Exception exception) {
//Handle the Exception here.
exception.printStackTrace();
}
In this example, the createOffer() now accepts only one parameter of type CreateOffer.
With the AXIS2 engine, the generated classes and stubs no longer have parameterized constructors.