1, Jaxwsproxyfactorybean
Introduction: The invocation of a similar mechanism with RMI, that is, the client directly calls the server-side service Interface (interface), CXF through the runtime proxy generation of the remote service proxy object, the client to complete the access to WebService ; several required fields: setaddress-This is the address we posted when we webservice, keep it consistent.
Cons: the benefit of invoking a service is that the invocation process is very simple, with a few lines of code completing a WebService call, but the client must also rely on the server-side interface, which is a very restrictive invocation method. Requiring server-side webservice to be Java implementations-and thus losing the meaning of using WebService
- public class client {
- public static void main (String[] args) {
- jaxwsproxyfactorybean bean = new jaxwsproxyfactorybean ();
- bean.setserviceclass (Helloworldservice. class
- bean.setaddress (
- HelloWorldService helloWorldService = (HelloWorldService) bean.create ();
- string result = helloworldservice.sayhello ( "Kevin"
- SYSTEM.OUT.PRINTLN (result);
- }
2,jaxwsdynamicclientfactory
Summary: Simply specify the location of the server-side WSDL file, then specify the parameters of the method and method to invoke, and do not care about how the service side is implemented.
- Public class Client3 {
- public static void main (String[] args) throws exception {
- jaxwsdynamicclientfactory clientfactory = jaxwsdynamicclientfactory.newinstance ();
- client client = clientfactory.createclient ( "http://localhost:9090/helloWorldService?wsdl"
- object[] result = client.invoke ( "SayHello" , "KEVIN"
- system.out.println (Result[0
- }
- }
3, Jaxwsserverfactorybean release with Jaxwsserverfactorybean, requires a separate jetty package.
Jaxwsproxyfactorybean and Jaxwsdynamicclientfactory