How to Consume a WebService using CXF in Eclipse

筅森魡賤 提交于 2019-12-07 17:20:31

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();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!