MyWSInterface dsws = service.getPort(PortQName,MyWSInterface.class); I'm working on a project that is running a webservice in localhost.I used jax-ws for this.When I had a client in the same project as the server, it worked fine.But now I'm trying to create a new client-project but i'm getting this error when i'm trying to run:Undefined port type: {http://test.main/}MyWSInterfaceI've copied the interface in both classes:package main.test;import javax.activation.DataHandler;import javax.jws.WebMethod;import javax.jws.WebService;import javax.jws.soap.SOAPBinding;import javax.jws.soap.SOAPBinding.Style;@WebService@SOAPBinding(style = Style.RPC)public interface MyWSInterface {@WebMethod public void sendTask(String convertType, String outputFileName, DataHandler dH);}I get this error on this line in my main test method:MyWSInterface dsws = service.getPort(MyWSInterface.class);Which is the 4th line in this method:private void runTest() throws MalformedURLException { URL url = new URL("http://localhost:8080/MyWS?wsdl"); QName qname = new QName("http://ws.sender.something.somecompany.com/", "MyWSInterfaceImplService"); Service service = Service.create(url, qname); DocShifterWS dsws = service.getPort(DocShifterWS.class); FileDataSource ds = new FileDataSource(new File("C:\\temp\\testinput.txt\\")); DataHandler dh = new DataHandler(ds); dsws.sendTask("pdf", "something.pdf", dh);} 解决方案 give endpointIneterface in @WebService annotation in the implementation class, if you dont give endpoint interface, you have to mention fully qualified port name while using getPort method.MyWSInterface dsws = service.getPort(PortQName,MyWSInterface.class); 这篇关于jax-ws客户端和服务器在单独项目中的未定义端口类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-21 11:14