3

I am connecting to an external WSDL using IntelliJ.

After connecting to the WSDL and generating my Java classes I am attempting to get a response from the service.

The service is not complicated at all just simple 'Yes', 'No' and 'Incorrect' message responses.

But I am getting a class cast exception involving PortInfo and Qname.

The method list call is as below.

 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));

And the error message I am getting is:

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)

picture of portinfo removed

Any help would be greatly appreciated.

Thank you

Ibbylun
  • 73
  • 1
  • 10

1 Answers1

1

Your problem is that a QName cannot be cast to a PortInfo. It is the following code that generates the error:

(PortInfo) new QName(...)

Why are you doing this cast? getHandlerChain() should be able to take in a QName instance.

dovetalk
  • 1,995
  • 1
  • 13
  • 21
  • getHandlerChain expects PortInfo. I will attach a photo to the original post. – Ibbylun Apr 03 '19 at 23:29
  • Hmm... I could've sworn I'd used a `HandlerResolver` that took `QName` in the `getHandlerChain`. You could get the `PortInfo` from the service description, or build one. All you need is a way to return the binding ID, port, and service names. – dovetalk Apr 04 '19 at 00:05
  • Well, how would one go about returning those in a way that wont cause a casting error. – Akjm Apr 04 '19 at 02:58