I am trying to consume a WEBSERVICE (http://www.detecno.mx/WCFTimbrador/DetecnoPac.svc?wsdl) using Eclipse and Apache CXF.
I already downloaded the latest Apache CXF version (2.5.2) from http://cxf.apache.org/ and already configured its location in Eclipse Preferences > Web Services > CXF 2.x Preferences
When trying to create the new Web Service Client in my project, I can't select Apache CXF as the WS runtime (OK button is disabled)
My project is not a dynamic web project, does it have to do with this? It is a normal Java Project, whose JAR is included in other Dynamic Web Projects.
The reason that the OK button is disabled is that you have not selected an existing server. Since it is a normal Java Project, you probably don't have or need to configure a server.
You can also create the web service client without using the Eclipse wizard, which may be simpler.
Using the wsimport command (available in the JDK), you can generate the required Java source files from the WSDL.
wsimport -s E:\workspace\cxf\src http://www.detecno.mx/WCFTimbrador/DetecnoPac.svc?wsdl
Below is an example of a method accessing the web service.
public static void main(String[] args) {
ServiceDetecnoPAC serviceDetecnoPAC = new ServiceDetecnoPAC();
IDetecnoPac port = serviceDetecnoPAC.getPort(IDetecnoPac.class);
((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://www.detecno.mx/WCFTimbrador/DetecnoPac.svc?wsdl");
Client client = ClientProxy.getClient(port);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
port.obtenerHoraServidor();
}
来源:https://stackoverflow.com/questions/25391606/how-to-consume-a-webservice-using-cxf-in-eclipse