Search code examples
javaxpathjaxbwsdlwsimport

"JAXWS wsimport" says XPath is null in a "jaxb file binding"


I am trying to generate stub files using jaxws wsimport. In the WSDL there are two types which are conflicting: line 68: <s:element minOccurs="0" maxOccurs="1" name="DAGSBROTTFELLT" type="s:string" />

and line 119: <s:element minOccurs="0" maxOccurs="1" name="DAGS_BROTTFELLT" type="s:string" />

The reason is that wsimport does not preserves the underscore character "_" and thinks that the both names are the same.

I have created a jaxb bindings file to name explicitly the resulting Java class.

But the wsimport says:

[ERROR] XPath error: null
line 11 of file:/C:/Users/deyan/ss_workspace/MVS%20Services/src/is/mvs/services/ws/xjb/companyInfo.xjb

I have tested the xpath string in http://www.freeformatter.com/xpath-tester.html#ad-output And it truly returns the element.

Please help to figure out why the wsimport says that the xpath is null.

Thank you in advance!

This is my WSDL: https://gognxml.uh.is/xml_service.asmx?WSDL

This is the jaxb bindings file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxws:bindings
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  wsdlLocation="https://gognxml.uh.is/xml_service.asmx?WSDL">

  <enableWrapperStyle>true</enableWrapperStyle>
  <enableAsyncMapping>false</enableAsyncMapping>
  <jaxws:bindings          node="wsdl:definitions/wsdl:types/s:schema/s:complexType[@name='Faersla']/s:sequence/s:element[@name='DAGS_BROTTFELLT']">
    <jaxb:class name="Dags_Brottfellt"/>
  </jaxws:bindings>
</jaxws:bindings>

Solution

  • One thing I notice is that the XPath expression uses the s namespace prefix (e.g. s:schema), but I don't see that namespace prefix declared anywhere. Is it supposed to be declared on one of the <jaxws:bindings> elements? Or where are such prefixes expected to be declared? Usually, having them declared in the input XML is not sufficient. But I don't know anything about wsimport.

    P.S. Looks like the xs prefix is not used, so maybe it was supposed to be s. As you already confirmed in your comment. :-)