尝试设置Web服务客户端时出现“prefix is null”错误

时间:2012-08-16 19:02:36

标签: 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)
...

对于我来说,看起来很像Service类试图将WSDL解析为其初始化的一部分,然后因为某些前缀为null而失败。行at com.sun.xml.internal.ws.wsdl.parser.ParserUtil.getQName(ParserUtil.java:78)表明它在解析QName时遇到问题。创建服务时,QName设置如下:

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

但错误信息不太清楚。是"MyService"之前需要的前缀,还是必需的WSDL更改(我不是WSDL所有者,因此很难将更改推送到其他团队)。

(环境是WAS 7.0的RAD 7.5)

1 个答案:

答案 0 :(得分:1)

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

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