views:

685

answers:

6

A variety of delphi demos I've built today with Delphi 2009 (update 3/4 applied) all seem to result in the client of any localhost web service I try to consume returning an "xml document must have a top level element" error

This includes, for example, even a demo as simple as http://blogs.embarcadero.com/pawelglowacki/2008/12/18/38624

What am I missing? What's wrong here? Very frustrating...

A: 

Hi,

Probably you have wrong generated XML data. Every XML document must have a top level element:

<xml version="..">
<topLevelElement>
 <element>
   ...
 </element>
 <element>
   ...
 </element>
<topLevelElement>

If this root element is missing, deserializer throws an exception.

Jan Remunda
Thank-you for your replyHowever, the mechanics of building the xml reply is handled by delphi automatically, correct? I mean if you look at Pawel's example above, there's no explicit construction of xmlMust be something I am missing still?
A: 

With a HTTP proxy, it is possible to see the Soap request and the XML.

Don's Proxy is very easy to use and can record HTTP communication to screen or to file:

http://donsproxy.sourceforge.net/

mjustin
+1  A: 

Try setting the following options for HTTPSoapPascalInvoker.Options:

soRootRefNodesToBody
soUTF8InHeader
soUTF8EncodeXML
eed3si9n
A: 

It most likely means you getting an HTML response from the server due to an error loading your SOAP library or an error within the SOAP library itself. The HTML cannot be parsed and results in this error.

A proxy can help you but you might want to have a look at Wireshark as it will allow you to sniff the traffic pretty easily and not specifically just for HTTP traffic.

Ryan VanIderstine
A: 

OK - this gets a little stranger ---

I've found that this all works under IIS but fails on apache (eed3si9n's solution DOES NOT work on apache)

Worse, I've found that under apache my basic cgi request content fields on POST are empty under apache - yet I simply deploy under IIS and it works just fine

So either the culprit is my apache install or there is something amiss under apache with delphi (surely that would be so widely reported and fixed)

So --- does anyone have any ideas what apache config options I should be looking at here?

Thank-you

A: 

Has there been any resolution to this problem? I've been looking in the Emarcadero forums and Quality Central and I haven't had any joy. Surely the only solution cannot be to just go back to Delphi 2007? That would be ridiculous...

Steve DC