java - 尝试设置 Web 服务客户端时出现 "prefix is null"错误

标签 java web-services wsdl rad qnames

我有一个 WSDL 和一些用于生成 JAX-WS Web 服务客户端的架构文件。当我尝试获取客户端实例时,我得到以下堆栈跟踪:

Caused by: java.lang.IllegalArgumentException: The specified prefix was null.
    at com.ibm.xml.xlxp.api.stax.msg.StAXMessageProvider.throwIllegalArgumentException(StAXMessageProvider.java:42)
    at com.ibm.xml.xlxp.api.stax.XMLStreamReaderImpl.getNamespaceURI(XMLStreamReaderImpl.java:721)
    at com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl$XMLStreamReaderProxy.getNamespaceURI(XMLInputFactoryImpl.java:212)
    at com.sun.xml.internal.ws.util.xml.XMLStreamReaderFilter.getNamespaceURI(XMLStreamReaderFilter.java:242)
    at com.sun.xml.internal.ws.wsdl.parser.ParserUtil.getQName(ParserUtil.java:78)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parsePortTypeOperationInput(RuntimeWSDLParser.java:721)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parsePortTypeOperation(RuntimeWSDLParser.java:694)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parsePortType(RuntimeWSDLParser.java:668)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:305)
    at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:136)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:227)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:190)
    at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:160)
    at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:92)
    at javax.xml.ws.Service.(Service.java:67)
...

It looks a lot to me like the Service class is trying to parse the WSDL as a part of its initialization, and then fails because some prefix is null. The line at com.sun.xml.internal.ws.wsdl.parser.ParserUtil.getQName(ParserUtil.java:78) suggests it's having trouble parsing the QName. When the service is created, the QName is set like this:

new QName("http://www.mycompany.ca/some/schema/MyService", "MyService")

但错误消息不太清楚。 “MyService” 之前是否需要前缀,或者是否需要对 WSDL 进行更改(我不是 WSDL 所有者,因此很难将更改推送给其他团队)。

(WAS 7.0 的环境为 RAD 7.5)

最佳答案

如果您检查堆栈跟踪的详细信息,您会发现问题出在 WSDL 中端口类型操作输入的名称上:

<wsdl:definitions .... > 
  <wsdl:portType .... >
    <wsdl:operation>
       <wsdl:input message="qname"/>    <--- your problem is here
    </wsdl:operation>
  </wsdl:portType >
</wsdl:definitions>

关于java - 尝试设置 Web 服务客户端时出现 "prefix is null"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11993758/

相关文章:

java - STRUTS2 - 值堆栈值在 URL 中传递!

java - 列出 jar 文件中的模块

web-services - WCF 测试客户端无法添加服务 - 无法获取元数据

facebook - REST Web 服务基本身份验证 + 客户端 Facebook 应用程序身份验证 = 双重身份验证?

java - 服务器不响应时 JAX-WS SOAP 服务卡住

java - Epub阅读器横版Android

java - 是否可以扩展 WebMvcConfigurationSupport 并使用 WebMvcAutoConfiguration?

ios - 从我的 iPhone 或 Blackberry 访问本地托管的 Web 服务

c# - ICerfiticatePolicy 和 ServicePoint

wsdl - 为什么 WSDL 引入 wsdl :message?