Apache Axis, XML document, errors abound

Discussion in 'Java' started by Jbjones, Oct 20, 2004.

  1. Jbjones

    Jbjones Guest

    I just wrote a simple java program that uses a web service call from
    the internet, and attempts to save it to a file.

    I have run a very similar program (actually used the same code) from a
    different machine, and it worked fine, though for somereason running it
    now is giving me errors. I have never seen this type of message
    before, so I am a bit confused.

    Here is the error:<error>
    Exception in thread "main" AxisFault
    faultCode:
    {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXParseException: Content is not allowed in
    prolog.
    faultActor:
    faultNode:
    faultDetail:
    {http://xml.apache.org/axis/}stackTrace:
    org.xml.sax.SAXParseException:
    Content is not allowed in prolog.
    </error>

    I use this almost exact same code in another program that is running on
    a web server that is running fine right now, so am not sure what to do.
    I have all the axis libraries and the xerces libraries in my jre ext's
    folder. Below I will include the pertinent code:

    I assume this is an error from axis and not from the code that I am
    running, but am lost.

    **Assume this is the only code used. I use other code, but it is
    provided in the packages. Any suggestions?
    <code>
    String xmlFile;

    // Needed for the web service with NOAA
    WeatherParametersType typeArray;
    typeArray = new WeatherParametersType();
    typeArray.setMaxt(true); //works
    typeArray.setMint(true); //works
    typeArray.setPop12(true);
    typeArray.setWspd(true);
    typeArray.setWx(true); //works
    typeArray.setIcons(true);

    String[] argst={"here","there"};
    //I assume this constructor has no bearing on anything
    Options opts=new Options(argst);

    NdfdXML ndfd = new NdfdXMLLocator();
    opts.setDefaultURL(ndfd.getndfdXMLPortAddress());

    URL serviceURL = new URL(opts.getURL());

    NdfdXMLPortType info = null;

    if(serviceURL!=null)
    {
    info = ndfd.getndfdXMLPort(serviceURL);
    }

    Calendar now = new GregorianCalendar();
    now.add(Calendar.DAY_OF_YEAR,0);
    Calendar next = new GregorianCalendar();
    next.add(Calendar.DAY_OF_YEAR,+7);
    //<latitude>38.84N</latitude>
    //<longitude>077.03W</longitude> is for zip 20001
    BigDecimal lat = new BigDecimal(38.84);
    BigDecimal lon = new BigDecimal(77.03);

    info.NDFDgen(lat,lon,(ProductType.value1),(now),(next),(typeArray));

    </code>

    I know this probably seems vague, so I will add any other code or help
    needed. Thanks for the help.

    J
     
    Jbjones, Oct 20, 2004
    #1
    1. Advertising

  2. Jbjones wrote:

    > Here is the error:<error>
    > Exception in thread "main" AxisFault
    > faultCode:
    > {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    > faultSubcode:
    > faultString: org.xml.sax.SAXParseException: Content is not allowed in
    > prolog.
    > faultActor:
    > faultNode:
    > faultDetail:
    > {http://xml.apache.org/axis/}stackTrace:
    > org.xml.sax.SAXParseException:
    > Content is not allowed in prolog.
    > </error>


    It appears that the service (apparently written in Java; possibly, but
    not necessarily, using Axis as SOAP interface) has found your SOAP
    request [see "Server.userException"] to be a malformed XML document [see
    "SAXParseException"]. The message cites an error in the document
    prologue, which is everything before the document's root element. I can
    think of at least two reasonably likely ways that this could happen, but
    there are any number of other possibilities. Look at the SOAP message
    received at the server; it may even have been logged for you. If you
    can't figure out what's wrong with it then someone here probably can.

    > I have all the axis libraries and the xerces libraries in my jre ext's
    > folder. Below I will include the pertinent code:


    If you knew what the pertinent code was then you could probably fix the
    program without our help. We generally want to see a small,
    self-contained example code -- compilable -- that exhibits the problem.
    You might even find the bug yourself while constructing it.

    > I assume this is an error from axis and not from the code that I am
    > running, but am lost.


    The error is _generated_ by Axis, but the bug is probably in your own
    code because you appear to be sending a malformed request to the service.

    > **Assume this is the only code used. I use other code, but it is


    It is evidently not the only code used because it is not compilable
    (even assuming the presence of class dependencies and assuming
    appropriate import statements).

    > provided in the packages. Any suggestions?


    I already offered some. In particular, if you want any more specific
    help then post a compilable example code such as I described.

    > <code>

    [...]
    > </code>
    >
    > I know this probably seems vague, so I will add any other code or help
    > needed. Thanks for the help.


    If you want us to devote time to helping you, then it would behoove you
    to show some initiative and try to give us from the start what we need
    to have to help you effectively. If your request seems vague even to
    you then why do you think it would be sufficient for us? Your comment
    there reads [to me] as "I'm too lazy to troubleshoot this myself, so
    I'll throw it out to the Net and see what I get back." (And that is
    largely the reason for the tone of this response.)


    John Bollinger
     
    John C. Bollinger, Oct 20, 2004
    #2
    1. Advertising

  3. Jbjones

    Jbjones Guest

    Thanks John, I solved the problem. I had thought it was the xml file
    that I was recieving that was throwing the error, (hence my confusion,
    because I never treated it as XML file, just a string). I knew it
    returned a valid xml file, and was befulled. You telling me it was the
    actual wbeb services server that was my problem allowed me to fix the
    problem in 45 seconds (The longitude should be negative for western
    hempisphere). I understand your tone, but realize i was looking at a
    weird error message (it didn't give me line numbers, just fault names,
    like i had never seen), and the net provides ZERO documentation on this
    to lead me to believe it was the server.
    So, regardless of your tone, you solved my issue quickly. Thanks
     
    Jbjones, Oct 21, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joey Vendetta
    Replies:
    0
    Views:
    3,471
    Joey Vendetta
    Apr 1, 2004
  2. Replies:
    0
    Views:
    955
  3. rhimbo
    Replies:
    0
    Views:
    5,510
    rhimbo
    Mar 16, 2006
  4. Tony Prichard
    Replies:
    0
    Views:
    760
    Tony Prichard
    Dec 12, 2003
  5. Fealfu
    Replies:
    1
    Views:
    1,755
    Jan =?UTF-8?B?VGhvbcOk?=
    Aug 28, 2007
Loading...

Share This Page