简体   繁体   中英

My question is about javax.xml.ws.WebServiceException: Undefined port type while trying to get port?

i would like to know why i have this exception in my client code. i have a wsdl and the web service interface only and try to call a methode oh this web service.

here is my client code :

   URL url = new URL("file:/C:/Projects/wsdl2.wsdl");
   QName qname = new QName("http://impl.service.proxy.ma/", "SPWSImplService");
   Service service = Service.create(url, qname);
   SPIntWS sPIntWS = service.getPort(SPIntWS.class);

i saw many cases like mine but in my case i cant give endpointIneterface in @WebService annotation in the implementation class. Here is some logs :

 Exception in thread "main" javax.xml.ws.WebServiceException: Undefined port type: {http://ws.client/}SPIntWS
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:349)
at com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:355)
at javax.xml.ws.Service.getPort(Service.java:188)
at scci.client.application.Client.sPIntWSProcess(Client.java:74)
at scci.client.application.Client.main(Client.java:44)

Thnx for your help.

In URL you were mentioning file path not host so you change this to

URL url = new URL("file:/C:/Projects/wsdl2.wsdl");

to be

URL url = new URL("http://localhost:8080/Projects/wsdl2.wsdl");

place your wsdl file under your workplace folder.

为了解决此错误,我使用了wsimport工具并生成了接口和实现,而无需更改客户端代码中的任何内容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM