Generate Service Proxy with Axis2
This page provides an example of generating a Web Service Capture Point service proxy using the Axis2 plug-in. See the list of tools used to generate clients in this document.
The following sample demonstrates how to send a Ping request and to print out the contents of the PingResponse.
import com.genesyslab.www.interaction.WebServiceCapturePointStub.*;
import com.genesyslab.www.interaction.*;
public class TestWSCP {
public static void main(String[] args) {
try {
WebServiceCapturePointStub serviceStub = new WebServiceCapturePointStub(
"http://zoolander.us.int.genesyslab.com:10080/Genesys/Interaction/WSCP_812_zoo/WebServiceCapturePoint");
Ping ping = new Ping();
KVList ext = new KVList();
// create a string kv pair
KVPair strPair = new KVPair();
KVPairValue value = new KVPairValue();
strPair.setKey("Source");
value.setValueString("I am coming from axis2 client");
strPair.setValue(value);
// add this pair to the extension
ext.addKvitem(strPair);
// set extension
ping.setExtension(ext);
PingResponse response = serviceStub.Ping(ping);
System.out.println("Ping response time:" + response.getEventTime());
printKVList("PingInfo", response.getPingInfo());
printKVList("UserData", response.getUserData());
printKVList("Extension", response.getExtension());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void printKVList(String name, KVList kvList) {
printKVList(name, kvList, "");
}
private static void printKVList(String name, KVList kvList, String shift) {
if (null == kvList) {
System.out.println(shift + name + "[KVList]=null");
} else {
System.out.println(shift + name + "[KVList]=");
for (KVPair pair : kvList.getKvitem()) {
KVPairValue value = pair.getValue();
if (null != value.getValueList()) {
printKVList(pair.getKey(), value.getValueList(), shift
+ "\t");
} else if (null != value.getValueString()) {
System.out.println(shift + "\t" + pair.getKey()
+ "[string]=" + value.getValueString());
} else {
System.out.println(shift + "\t" + pair.getKey() + "[int]="
+ value.getValueInt());
}
}
}
}
}
This page was last edited on April 17, 2020, at 18:11.
Comments or questions about this documentation? Contact us for support!
