1

this is my first time looking for help here and I hope someone can help me out.

I have been given the task to localize our ant build process after to help reduce build time.

The idea goes something like building an ant task that downloads WSDLs associated with a specific service and save them locally. Long story short, this has been done but for some reason when building a service using the local files I get a 'Content is not allowed in prolog' error in the first imported XSD.

I have searched forums and the most common response is hidden characters before the prolog but I have check the hex code and there are no hidden chars.

This is the WSDL prolog

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

This is the first XSD prolog

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

Prolog in hex

   3C3F786D6C2076657273696F6E3D2231
   2E302220656E636F64696E673D227574
   662D3822207374616E64616C6F6E653D
   226E6F223F3E

Which are the same as the remote versions.

This is how the downloaded XSDs and WSDLs are saved also.

private Document convertToXML(String xmlSource) throws Exception {
    DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xmlSource)));
    return document;
}


    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.STANDALONE, "no");
    transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8");
    Result output = new StreamResult(new File(filePath));

Let me know if I should be more specific or if I need to add more info.

Thanks.

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
bhumphrey
  • 625
  • 1
  • 6
  • 13
  • Ok I think it must be something to do with the way the file is being saved, because I just replaced the code in existing local XSD with the code from the downloaded version and it worked fine... – bhumphrey Jul 30 '13 at 15:39
  • Check this link - http://stackoverflow.com/questions/3665554/about-saxparseexception-content-is-not-allowed-in-prolog/7023984 – junkiecoder Jul 31 '13 at 05:44
  • Thanks, I actually just figured it out. I was the schemaLocation in the WSDL to "exampleschemas\example1\schema.xsd" as soon as I put all of the schemas into the same folder as the WSDL and altered the schemaLocation to match it worked fine. – bhumphrey Aug 01 '13 at 15:58

2 Answers2

1

The problem was in the WSDL that I was altering.

Original WSDL

   <xsd:import namespace="http://someNameSpace" 
         schemaLocation="http://someLocation/dir1/dir2/schema.xsd"/>

Problematic WSDL

   <xsd:import namespace="http://someNameSpace" 
         schemaLocation="dir1/dir2/schema.xsd"/>

Working WSDL

   <xsd:import namespace="http://someNameSpace" 
         schemaLocation="schema.xsd"/>

So now the WSDL and XSDs are all in the same directory with no sub-directories.

bhumphrey
  • 625
  • 1
  • 6
  • 13
0

Open the XSD/WSDL in notepad++, click on Encoding menu and choose it to UTF-8 and check whether there are any unnecessary characters. Please ensure that there is no space in the first line of your XSD / WSDL

  • Yes I have done that. This is the prolog in hex.3C3F786D6C2076657273696F6E3D2231 2E302220656E636F64696E673D227574 662D3822207374616E64616C6F6E653D 226E6F223F3E – bhumphrey Jul 30 '13 at 15:09