0% found this document useful (0 votes)
2 views1 page

MathConsumer_default_0441beaf6acfaf394fa5cef72c11c0f1

The document is a Java program that utilizes Apache CXF to create a client for a web service. It sets up a proxy factory to connect to a MathUtility service and calls two methods: factorial and addIntegers. The results of these operations are printed to the console, and exceptions are handled for potential errors.

Uploaded by

fjrppbr8xc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

MathConsumer_default_0441beaf6acfaf394fa5cef72c11c0f1

The document is a Java program that utilizes Apache CXF to create a client for a web service. It sets up a proxy factory to connect to a MathUtility service and calls two methods: factorial and addIntegers. The results of these operations are printed to the console, and exceptions are handled for potential errors.

Uploaded by

fjrppbr8xc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import org.apache.cxf.jaxws.

JaxWsProxyFactoryBean;

public class MathConsumer {

public static void main(String[] args) {

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

// Use the URL defined in the soap address portion of the WSDL

factory.setAddress("http://localhost:8080/MathUtility/services/MathUtilityPort");

// Utilize the class which was auto-generated by Apache CXF wsdl2java


factory.setServiceClass(MathUtility.class);

Object client = factory.create();

try {

// Call the Web Service to perform an operation


int response = ((MathUtility)client).factorial(5);

System.out.println(response);
int response2 = ((MathUtility)client).addIntegers(5,2);

System.out.println(response2);

} catch (SecurityException e) {

e.printStackTrace();

} catch (IllegalArgumentException e) {

e.printStackTrace();

}
}
}

You might also like