本文介绍了clientgen生成的PortType_Stub无法强制转换为javax.xml.ws.BindingProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试通过客户端访问Web服务时,我无法获取requestContext。我试图像这样访问requestContext:

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

但是当我执行时:

我得到:

任何建议/帮助表示赞赏。在此先感谢。

Any suggestions / help is appreciated. Thanks in advance.

推荐答案

我发现:


  • ((javax.xml.ws.BindingProvider)qport)可以安全地在使用 JAX-WS 生成的WSDL接口上调用( by wsimport

  • ((javax.xml.rpc.Stub)qport)可以安全地在 JAX-RPC 客户端上调用(由 clientgen 创建)

  • ((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)

在我的例子中,我用 clientgen (JAX-RPC)创建了WSDL接口,因此属性可以设置如下:

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

这篇关于clientgen生成的PortType_Stub无法强制转换为javax.xml.ws.BindingProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 18:45