Client端调用:
public class FourClass_PortTypeClient {
public static void main(String[] args) throws Exception {
QName serviceName = new QName("http://four.com/", "FourClassService");
QName portName = new QName("http://four.com/", "FourClassPort");
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
"http://localhost:8080/WebserviceServer/services/FourClassPort");
com.four.FourClass_PortType client = service.getPort(portName, com.four.FourClass_PortType.class);
System.out.println(client.doMethodFour("ssd"));
// Insert code to invoke methods on the client here
}
}
调用报错;
Exception in thread "main" javax.xml.ws.WebServiceException: WSDL Metadata not available to create the proxy, either Service instance or ServiceEndpointInterface com.four.FourClass_PortType should have WSDL information
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:308)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:295)
at javax.xml.ws.Service.getPort(Service.java:92)
at com.four.FourClass_PortTypeClient.main(FourClass_PortTypeClient.java:27)
问题解决:
Client端项目缺少Webservice调用的包
添加Cxf.zip解决问题
public class FourClass_PortTypeClient {
public static void main(String[] args) throws Exception {
QName serviceName = new QName("http://four.com/", "FourClassService");
QName portName = new QName("http://four.com/", "FourClassPort");
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
"http://localhost:8080/WebserviceServer/services/FourClassPort");
com.four.FourClass_PortType client = service.getPort(portName, com.four.FourClass_PortType.class);
System.out.println(client.doMethodFour("ssd"));
// Insert code to invoke methods on the client here
}
}
调用报错;
Exception in thread "main" javax.xml.ws.WebServiceException: WSDL Metadata not available to create the proxy, either Service instance or ServiceEndpointInterface com.four.FourClass_PortType should have WSDL information
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:308)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:295)
at javax.xml.ws.Service.getPort(Service.java:92)
at com.four.FourClass_PortTypeClient.main(FourClass_PortTypeClient.java:27)
问题解决:
Client端项目缺少Webservice调用的包
添加Cxf.zip解决问题