Jump to: navigation, search

Apache CXF—Java Client

To generate a Web Service Capture Point service proxy for Java use the wsdl2java tool:

wsdl2java -frontend jaxws21 -d <output directory> <WSDL URL>

For example:

wsdl2java -d c:\Temp\MyJSClient 
http://zoolander.us.int.genesyslab.com:10080/Genesys/Interaction/WSCP_812_zoo/WebServiceCapturePoint?wsdl

The tool generates a set of files for the proxy.

Create a simple Java console application to ping the service:

import java.net.URL;
import javax.xml.ws.Holder;
import com.genesyslab.interaction.*;

public class Test {
    public static void main(String[] args) throws Exception {
	
	
      WebServiceCapturePoint service = new WebServiceCapturePoint(new 
URL("http://zoolander.us.int.genesyslab.com:10080/Genesys/Interaction/WSCP_812_zoo/WebServiceCapturePoint/?WSDL"));
	
      IWebServiceCapturePoint cp = service.getIWebServiceCapturePointHttpBinding();
	
      KVPairValue val = new KVPairValue();

      val.setValueString("I am coming from CXF client");

      KVPair pair = new KVPair();
	
      pair.setKey("Source");
      pair.setValue(val);

      KVList extList = new KVList();
	
      extList.getKvitem().add(pair);

      Holder<KVList> extension = new Holder<KVList>(extList);
	
      Holder<String> eventTime = new Holder<String>();	
      Holder<KVList> userData = new Holder<KVList>();
      Holder<KVList> pingInfo = new Holder<KVList>();
	
      cp.ping(extension, eventTime, userData, pingInfo);

      System.out.println("Ping response time:" + eventTime.value);
      printKVList("PingInfo", pingInfo.value);
      printKVList("UserData", userData.value);
      printKVList("Extension", extension.value);
    }
    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 (value.getValueInt() != null) {
	       System.out.println(shift + "\t" + pair.getKey() + "[int]="
	            + value.getValueInt());
	    } else if (null != value.getValueList()) {
	       printKVList(pair.getKey(), value.getValueList(), shift
	            + "\t");
	    } else {	
               System.out.println(shift + "\t" + pair.getKey()
                    + "[string]=" + value.getValueString());	
            }	
         }
      }
   }
}
This page was last edited on June 18, 2020, at 10:43.
blog comments powered by Disqus