WSDL を直接使用する既存の実装

この情報は、IBM® Campaign バージョン 8.6 以上にアップグレードし、現在 WSDL を使用して Campaign Web アプリケーションと対話している場合に関係があります。Campaign Web サービスの WSDL は、 サード・パーティー製のコンバーター・ツールを使用してクライアント・サイド・スタブおよびサポートするクラスを生成するために使用されます。ここに示す例は、Apache AXIS2 1.5.2 の WSDL2Java ツールを使用しています。

WSDL の場所およびサービス URL

IBM CampaignCampaign Web サービスは、 次の場所に配置されます。

http://host:port/Campaign/services/CampaignServices30Service

対応する WSDL は、次の場所から取得できます。

http://host:port/Campaign/services/CampaignServices30Service?wsdl

スタブおよびクラスの生成

Apache AXIS2 1.5.2 の WSDL2Java ツールは、スタブおよびサポートする Java™ クラスを WSDL から生成するために使用できます。サンプルの Ant タスクがここに示されています。

このツールは、類似の引数のセットを使用して、コマンド・ラインからも使用できます。引数値は環境に合うように変更できます。

注: 次の WSDL2Java コンバーター例には、デフォルトの ADB バインディングが使用されます。
<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>

生成されたスタブおよびサポートするクラスの使用

スタブは以下の方法で使用できます。

CampaignServices30ServiceStub serviceStub = new 
CampaignServices30ServiceStub(serviceURL);

serviceStub._getServiceClient().getOptions().setTimeOutInMilliSeconds
(webServiceTimeout); //Timeout in milliseconds.

オファーは以下の方法で作成できます。

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();
}

この例で、createOffer() はタイプ CreateOffer のパラメーターを 1 つだけ受け入れるようになりました。

AXIS2 エンジンでは、生成されるクラスおよびスタブにパラメーター化されたコンストラクターがなくなりました。