我使用IntelliJ连接到外部WSDL。
在连接到WSDL并生成我的Java类之后,我试图从服务获得响应。
该服务并不复杂,只是简单的“是”,“否”和“不正确”的消息响应。
但是我得到了一个涉及PortInfo
和Qname
的类演员异常。
方法列表调用如下。
Service helloService = Service.create(
helloWsdlUrl,
new QName(nameSpaceUri, serviceName));
List list = helloService.getHandlerResolver().getHandlerChain(
(PortInfo) new QName(nameSpaceUri, portName));
list.add(new HandlerInfo((Class) null, (Map)null, (QName[])null));
我得到的错误信息是:
Exception in thread "main" java.lang.ClassCastException:
javax.xml.namespace.QName cannot be cast to javax.xml.ws.handler.PortInfo
at Client.main(Client.java:37)
任何帮助将不胜感激。
谢谢
你的问题是,QName
无法投射到PortInfo
。以下代码生成错误:
(PortInfo) new QName(...)
你为什么要这样演员? getHandlerChain()
应该能够接受QName
实例。