clientgen generated PortType_Stub cannot be cast to javax.xml.ws.BindingProvider

拟墨画扇 提交于 2019-12-08 07:05:10

问题


While trying to access a webservice through a client, I am not able to get the requestContext. I am trying to access the requestContext like this:

QuerySysStatService querySystem=new QuerySysStatService_Impl(wsdl);
QuerySysStatPortType qport=querySystem.getQuerySysStatPortType();
Map<String, Object> rContext =((BindingProvider)qport).getRequestContext();

But when I execute:

((BindingProvider) qport)

I get:

java.lang.ClassCastException: com.demo.client.service.QuerySysStatPortType_Stub cannot be cast to javax.xml.ws.BindingProvider

Any suggestions / help is appreciated. Thanks in advance.


回答1:


I found that:

  • ((javax.xml.ws.BindingProvider) qport) can safely be called on WSDL interfaces generated with JAX-WS (by wsimport)
  • ((javax.xml.rpc.Stub) qport) can safely be called on JAX-RPC clients (created by clientgen)

In my case I created the WSDL interfaces with clientgen (JAX-RPC), so the properties could be set as below:

javax.xml.rpc.Stub stub = (javax.xml.rpc.Stub) qport;
stub._setProperty("KEY","Value");


来源:https://stackoverflow.com/questions/9946284/clientgen-generated-porttype-stub-cannot-be-cast-to-javax-xml-ws-bindingprovider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!