利用cxf 开发web service 并利用cxf的wsdl2java开发client

Server:

import javax.jws.WebParam;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
@WebService
@SOAPBinding(style = Style.RPC)
public class HelloService {
public String sayHello(@WebParam(name = "name") String name) {
return name + " say: Hello World ";
}

}


wsdl2java -p com.test.cxf.client -client http://localhost:9000/helloWorld?wsdl


生成:




Client:

public class MainClient {


public static void main(String args[]){
HelloService service = new HelloServiceService().getHelloServicePort();
System.out.println(service.sayHello("Tom"));
}
}


你可能感兴趣的:(java,Web,webservice,String,service,Class)