1 Reply Latest reply on Jan 14, 2010 2:22 PM by olegkon

    SAXParseException passing param from AIR to Web Service

    olegkon Level 1

      Hi,

       

      I am trying to call Java Web Service from AIR application

      and pass it data parameter (String in XML format):

      <srv:Excel7UtilService id="excelService"
              GetExcelData_result="getExcelDataResponse(event)"   
              SetExcelData_result="setExcelDataResponse(event)"   
              fault="wsFault(event)" >
              <srv:getExcelData_request_var>
                      <srv:GetExcelData_request fileName="c:\temp\oleg1.xlsx"/>
                  </srv:getExcelData_request_var>
                  <srv:setExcelData_request_var>
                      <srv:SetExcelData_request id="setData" fileName="c:\temp\oleg2.xlsx" data="{_data}"/>
                  </srv:setExcelData_request_var>   
                  <srv:readWriteExcelData_request_var>
                    <srv:ReadWriteExcelData_request inputFileName="c:\temp\oleg1.xlsx" outputFileName="c:\temp\oleg3.xlsx"/>
                  </srv:readWriteExcelData_request_var>       
            </srv:Excel7UtilService>

       

      Getting Java Exception:
      org.xml.sax.SAXParseException: Reference is not allowed in prolog.
          at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
          at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
          at util.Excel7Util.setExcelData(Excel7Util.java:148)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
          at java.lang.reflect.Method.invoke(Method.java:597)
          at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
          at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
          at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
          at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
          at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
          at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
          at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
          at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
          at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)

       

      Java code:

      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      InputSource is = new InputSource();
      is.setCharacterStream(new StringReader(data));      // ?

      Document doc = db.parse(is);     <-----  Exception here

      NodeList nodes = doc.getElementsByTagName("row");

      ......

       

      After googling up that exception, found that "this error is caused by additional characters at the start of the XML file."

       

      And noticed that my data on receiving end is messed up, all "<" become  "&lt;" ,

      so for example <root> becomes "&lt;root>"

       

      Do I need to do some encoding / decoding ?   In Java or Flex ?

       

      Please help !

       

      TIA,

      Oleg.