2

I apologise if this is a duplicate question - I looked for quite a file and found very many similar questions, but nothing quite the same as this.

I'm trying to generate Java client bindings using wsimport for a web service with the WSDL specified at this URL: https://api.dss.gov.au/datacollection/dex?wsdl However, I keep getting errors like this:

[ERROR] Premature end of file. line 1 of http://api.dss.gov.au/datacollection/dex?WSDL&type=XSD&file=file%3A%2FC%3A%2Ftfs%2FCCSApps%2FDataCollection%2FBranches%2FMR17.11%2FOSB%2FDataCollection.Assessment%2FResources%2FSchema%2FAssessment.External.xsd

[ERROR] org.xml.sax.SAXParseException; systemId: http://api.dss.gov.au/datacollection/dex?WSDL&type=XSD&file=file%3A%2FC%3A%2Ftfs%2FCCSApps%2FDataCollection%2FBranches%2FMR17.11%2FOSB%2FDataCollection.Assessment%2FResources%2FSchema%2FAssessment.External.xsd; lineNumber: 1; columnNumber: 1; Premature end of file. line 2 of https://api.dss.gov.au/datacollection/dex?wsdl

It is failing while trying to download/parse the very first schema file listed in the WSDL.

I am running this on Windows 10. I have tried JDK 1.8 and Java 9. I have tried generating it using the Eclipse Web Developer Tools, and by using the jaxws-maven-plugin, and by using wsimport directly - they all fail with the same error. So presumably the error is something to do with the core jax-ws implementation and not with any of the wrappers.

I have plugged the schema URL into my browser window (on the same machine as my dev) and verified that it downloads properly. At a glance it seems to be a well-formed schema file - it certainly isn't zero-length, as this error would imply.

Thinking perhaps this was a permissions issue, I tried the fixes suggested in this question: WebService Client Generation Error with JDK8 Unfortunately, they didn't work either.

I have tried downloading the WSDL and the offending schema file to my local dir and then updating the schema link in the WSDL to point to the local copy of the schema file. This does seem to fix the issue - however, it then fails on the next schema file. I started a manual process of downloading the schema file all locally and updating the links, but there seem to be dozens of schema files. It also doesn't seem to be a sustainable way of developing against this web service going forward if the API changes.

Answers to this could consist of any of the following:

  1. Show me what I am doing wrong to cause this error, and allow me to fix it to automatically generate the Java bindings from this WSDL.
  2. An a free alternative tool to wsimport to achieve the same functionality.
  3. Reference to a bug report for wsimport showing that this is a known issue that hasn't been resolved..
Fr Jeremy Krieg
  • 482
  • 5
  • 13
  • 1
    Have you tried to load this WSDL into SoapUI and see what will happen? The second option is to try the wsimport utility from another implementation of JAX-WS (Apache CXF or whatever). – Alex Sergeenko Jul 20 '18 at 09:04
  • Thank you for the suggestion, @AlexSergeenko. I tried it with Apache CXF and got the same error. I have managed to get a client up and running using an all-in-one WSDL file (which embeds the XSD directly rather than importing it) supplied by the service author. However, I think that the question is still relevant. – Fr Jeremy Krieg Jul 23 '18 at 02:02

2 Answers2

2

I opened the faulty XSD file in XML editor and it shows The reference to entity "type" must end with the ';' delimiter.. The & ampersand signs are not escaped in the schema import, and that is across all other schema imports. &type=XSD&file=file

That is upto to WSDL author to either escape ampersands or get rid of optional type and file entities in imports within XSD files, it would do the trick.

makara
  • 76
  • 5
  • I think you might be right. In the process of downloading the files locally, I think I was also fixing that encoding which fixed the problem. I'm not sure how I'll go getting the author to fix the original, but I have another workaround for now. Even I get a chance I'll test this and Mark your answer current if it works. Thanks. – Fr Jeremy Krieg Dec 11 '18 at 13:46
  • @FrJeremyKrieg would you mind sharing your workaround. I am in the process of getting staging and system account credentials, not able to request things from department at this stage. Is the all-in one WSDL file made available to the community? Many thanks – makara Dec 12 '18 at 03:42
  • makara, the workaround at the moment is to use cxf-codegen-plugin with the all-in-one WSDL that the department provided me. I've managed do to a Ping test and some other simple operations. Unfortunately, I'm not sure what the terms are from the department on the use of this file (ie, whether I'm allowed to share it with the general community). But if you're already in the process of getting your login it won't be too long before they email you the WSDL too. – Fr Jeremy Krieg Dec 13 '18 at 05:45
0

must me problem with xml declaration.Download the WSDL and try to generate the client using any IDE . i.e. Eclipse.

Yash
  • 108
  • 1
  • 1
  • 7