javax.xml.ws.WebServiceException:即使定义了endpointInterface,也未定义端口类型

时间:2019-06-23 14:19:27

标签: java soap

即使我为服务端点接口(SEI)实现定义了endpointInterface,也遇到了getport错误

  

线程“ main”中的异常javax.xml.ws.WebServiceException:未定义的端口类型:{http://soaptestclient.example.com/} iSoapEndPoint

以下与同一问题有关的问题和答案没有帮助我解决问题

Java WebServiceException: Undefined port type with JBoss

javax.xml.ws.WebServiceException: Undefined port type Java Struts SOAP WSDL

服务端点界面

package com.example.soaptest1;
...
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface iSoapEndPoint {
    @WebMethod String getHelloWorldAsString(String name);
}

服务端点接口实现

package com.example.soaptest1;
...
@WebService(endpointInterface = "com.example.soaptest1.iSoapEndPoint")
public class SoapEndPointImpl implements iSoapEndPoint{
    @Override
    public String getHelloWorldAsString(String name) {
        return "Hello World JAX-WS " + name;
    }    
}

服务端点发布者

public class SoapEndPointPublisher {
    public static void main(String[] args){
        Endpoint.publish("http://192.168.1.11:9999/ws/hello", new SoapEndPointImpl());
    }
}

最后是客户端

    public class SoapClient {
        public static void main (String [] args) throws Exception{

            URL url = new URL("http://192.168.1.11:9999/ws/hello?wsdl");

            QName qname = new QName("http://soaptest1.example.com/", "SoapEndPointImplService");

            Service service = Service.create(url,qname);

     if one has enough experience in "reading" wsdl 
            iSoapEndPoint soapEndPointInterface = service.getPort(iSoapEndPoint.class);  
     //The interface iSoapEndPoint was copied from the EndPoint 
     //Java project to the client Java project so that I can import it since I'm not using wsimport      
            System.out.println(soapEndPointInterface.getHelloWorldAsString("Hello"));
        }
    }

0 个答案:

没有答案