javaweb-serviceswsdlradqnames

"prefix is null" error when attempting to set up web service client


I have a WSDL and some schema files that I used to generate a JAX-WS web service client. When I try to get an instance of the client, I get this stack trace:

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

The error message is not too clear though. Is a prefix needed before "MyService" or are changes to the WSDL necessary (I am not the WSDL owner so changes are difficult to push to other teams).

(environment is RAD 7.5 for WAS 7.0)


Solution

  • If you examine the details of the stack trace, you'll notice that the problem is with the name of a port type operation input in the WSDL:

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