我有一个 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/