Tuesday, May 10, 2016

Exposing and Consuming JAVA Webservice as CXF using JDK1.7

Note: JDK 1.8 is having issue and we have WTP plugin till 2.X version of CXF hence used CXF 2.7.1 Jar even though latest CXF 3.2 version is available.

Eclipse Set UP :- Image_1

Image_2

Image_3

Installing CXF
Image_1

Image_2

CXF Server Project and CXF Client Project using Eclipse

Image_1Image_2Image_3Image_4Image_5Image_6Image_7Image_8Image_9Image_10Image_11Image_12Image_13Image_14Image_15Image_16Image_17Image_18Image_19Image_20Image_21Image_22Image_23Image_24Image_25Image_26Image_27Image_28Image_29Image_30Image_31Image_32Image_33Image_34Image_36Image_37Image_38Image_39Image_40Image_41
package com.test;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;

public class TestSiddhuMain {
private static final QName SERVICE_NAME = new QName("http://test.com/", "TestSiddhuService");

public static void main(String args[])
{
try {
URL wsdlURL = TestSiddhuService.WSDL_LOCATION;
if (args.length > 0 && args[0] != null && !"".equals(args[0])) {
File wsdlFile = new File(args[0]);
try {
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}

TestSiddhuService ss = new TestSiddhuService(wsdlURL, SERVICE_NAME);
TestSiddhu port = ss.getTestSiddhuPort();

{
System.out.println("Invoking add...");
java.lang.String _add_arg0 = "3";
java.lang.String _add_arg1 = "4";
java.lang.String _add__return = port.add(_add_arg0, _add_arg1);
System.out.println("add.result=" + _add__return);

}
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

No comments: