java - javax.xml.ws.WebServiceException:未定义的端口类型,即使定义了端点接口
问题描述
即使我为服务端点接口 (SEI) 实现定义了 endpointInterface,我还是得到了 getport 错误
线程“主”javax.xml.ws.WebServiceException 中的异常:未定义的端口类型:{ http://soaptestclient.example.com/ }iSoapEndPoint
以下与同一问题相关的问题和答案并没有帮助我解决它
Java WebServiceException:带有 JBoss 的未定义端口类型
javax.xml.ws.WebServiceException:未定义的端口类型 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"));
}
}
解决方案
推荐阅读
- python - 如何在任务栏中将图标设置为 kivy 应用程序?
- javascript - 将 JSON 转换为 JQuery 数据表
- c - 声明一个变量并在编译时将其添加到数组中
- angular - 从 Angular 中的 PrimeNG PickList 中删除按钮
- ios - 如何观察属性在 RxSwift 中的特定时间间隔内是否没有变化
- c# - 在模型中创建与其自身的多对多关系
- mysql - MYSQL中AND,OR运算符在检索行时有什么区别?
- git - 为什么当我 git status 时看到“HEAD detached from”?
- c - 我尝试编写一个函数来删除字符串中的所有字符(期望字母表)。但我的代码有问题
- c++ - C++ 指数分布偶尔会返回预期为 0 的 inf