Current function:
HTTP:TIdHTTP;
var
XMLRequest, XMLResponse : TStringStream;
HTTP.Post('https://apidemoeu.webex.com/WBXService/XMLService',XMLRequest,XMLResponse);
The response is saying the Document root element is missing.
Any suggestions or ideas?
Regards,
Rich
uses ..., MSXML2_TLB, COMObj;
var
oXMLHTTP: IXMLHTTPRequest;
oXMLDoc: IXMLDOMDocument2;
begin
oXMLHTTP := CreateOleObject('MSXML2.ServerXMLHTTP') as
IXMLHTTPRequest;
try
oXMLDoc := CreateOleObject('MSXML2.DOMDocument.3.0') as
IXMLDOMDocument2;
try
oXMLHTTP.open('POST',
'https://apidemoeu.webex.com/WBXService/XMLService', False, '', '');
oXMLHTTP.send(EmptyParam);
finally
oXMLDoc.LoadXML(Trim(oXMLHTTP.ResponseText));
oXMLHTTP := nil;
end;
finally
ShowMessage(oXMLDoc.XML);
oXMLDoc := nil;
end;
end;
> var
> XMLRequest, XMLResponse : TStringStream;
>
>
>
HTTP.Post('https://apidemoeu.webex.com/WBXService/XMLService',XMLRequest,XMLResponse);
Try this instead:
uses .., MSXML2_TLB, ComObj;
procedure TForm1.GetXML;
var
oXMLHTTP :IXMLHTTPRequest;
begin
oXMLHTTP := CreateOleObject('MSXML2.XMLHTTP') as IXMLHTTPRequest;
try
oXMLHTTP.open('POST',
https://apidemoeu.webex.com/WBXService/XMLService, False, '', '');
oXMLHTTP.send(EmptyParam);
finally
XMLDocument.LoadXML(Trim(oXMLHTTP.ResponseText));
oXMLHTTP := nil;
end;
end;
To clarify, I'm using Delphi 2006. Where can I get MSXML2_TLB?
Rich
"Eddie Shipman" <mr_delphi...@nospamyahoo.com> wrote in message
news:xn0feb6zf...@forums.borland.com...
I'm using NativeXML to create the XMLRequest.
Rich
"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:47505a97$1...@newsgroups.borland.com...
>
> "Rich Rohde" <ri...@richware.net> wrote in message
> news:4750...@newsgroups.borland.com...
>
>> The response is saying the Document root element is missing.
>
> Is that what the actual server response data says, or is that what your
> processing of the data says when you try to load it afterwards? What are
> you actually doing with XMLResponse after Post() exits? Did you remember
> to set the Position property back to 0 first?
>
>
> Gambit
>
>
<?xml version="1.0" encoding="UTF-8"?>
<serv:message xmlns:serv="http://www.webex.com/schemas/2002/06/service"
xmlns:com="http://www.webex.com/schemas/2002/06/common">
<serv:header>
<serv:response>
<serv:result>FAILURE</serv:result>
<serv:reason>Document root element is missing.</serv:reason>
<serv:gsbStatus>PRIMARY</serv:gsbStatus>
<serv:exceptionID>999999</serv:exceptionID>
</serv:response>
</serv:header>
<serv:body/>
</serv:message>
The request is:
<?xml version="1.0" encoding="UTF-8"?>
<serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<securityContext>
<webExID>**********</webExID>
<password>********</password>
<siteID>********</siteID>
<partnerID>********</partnerID>
</securityContext>
</header>
<body>
<bodyContent
xsi:type="java:com.webex.service.binding.ep.GetAPIVersion"/>
</body>
</serv:message>
"Remy Lebeau (TeamB)" <no....@no.spam.com> wrote in message
news:47505a97$1...@newsgroups.borland.com...
>
> "Rich Rohde" <ri...@richware.net> wrote in message
> news:4750...@newsgroups.borland.com...
>
>> The response is saying the Document root element is missing.
>
> The response is saying the Document root element is missing.
Is that what the actual server response data says, or is that what your
> The Actual response is:
There is clearly a root element in that data.
You did not answer my question about how you are using XMLResponse after
Post() exits. So I am guessing that you are passing it as-is to a function
that takes a TStream as input, and did not set the Position property to 0
beforehand. Am I right?
Gambit
I'm not sure I really understand your question. Before the post the
XMLResponse is created:
XMLResponse := TStringStream.Create('');
After the post, I'm using NativeXML to format the XML to a TString and
showing the information in a TMemo control.
Rich
> I'm not sure I really understand your question.
What exactly are you doing with the XMLResponse stream after Post() finishes
its work? Please show that actual code. I don't know how to be any clearer
than that.
> After the post, I'm using NativeXML to format the XML to
> a TString and showing the information in a TMemo control.
But you did not show any of the code you are using to do all of that. You
haven't shown anything you are doing after calling Post(). I have never
looked at NativeXML, so I do not know what kind of input it takes. Does it
accept a TStream object or a String value, for instance? It makes a
difference.
Gambit
Import the type library.
or possibly:
#import "msxml3.dll"
using namespace MSXML2;
Okay, generated the code as shown and I'm getting nothing with some errors.
Here's the code I used:
procedure TWAMF.GetXML;
var
XMLHTTP : IXMLHTTPRequest;
XMLDoc : IXMLDomDocument2;
const
URL = 'https://apidemoeu.webex.com/WBXService/XMLService';
begin
XMLHTTP := CreateOleObject('MSXML2.ServerXMLHTTP') as IXMLHTTPRequest;
try
XMLDoc := CreateOleObject('MSXML2.DOMDocument.3.0') as
IXMLDOMDocument2;
try
XMLHTTP.open('POST', URL, False, '', '');
XMLHTTP.Op
finally
XMLDoc.LoadXML(Trim(XMLHTTP.ResponseText));
XMLHTTP := nil;
end;
finally
ShowMessage(XMLDoc.xml);
XMLDoc := nil;
end;
end;
function TWAMF.GetXMLstr: boolean;
var
strXML : string;
i : integer;
sl : TStrings;
XMLRqst : string;
XMLResponse : TStringStream;
XMLRequest : TStringStream;
const
URL = 'https://apidemoeu.webex.com/WBXService/XMLService';
begin
sl := TStringList.Create;
XMLRequest := TStringStream.Create('');
XMLResponse := TStringStream.Create('');
GetVersion(XMLRequest);{ This routine uses NativeXML to create XML
Request }
FormatXML(sl,XMLRequest);
memXML.Lines.Text := sl.Text;
memXML.Lines.Add('<<<<<<<< Response Follows >>>>>>>>>>');
SSLIO.SSLOptions.Method := sslvSSLv3;
HTTP.ReadTimeout := 10000;{ IdTimeoutInfinite; }
HTTP.ConnectTimeout := 10000;
HTTP.IOHandler := SSLIO;
sl.Text := XMLRqst;
HTTP.Request.ContentType := 'text/xml';
HTTP.HTTPOptions := [];
XMLResponse.Position := 0;
XMLRequest.Position := 0;
HTTP.Post(URL,XMLRequest, XMLResponse);
HTTP.Disconnect;
memXML.Lines.Text := memXML.Lines.Text + XMLResponse.DataString;
sl.Free;
XMLRequest.Free;
XMLResponse.Free;
end;
Here's the data in the TMemo field:
<?xml version="1.0" encoding="UTF-8"?>
<serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<securityContext>
<webExID>***</webExID>
<password>***</password>
<siteID>***</siteID>
<partnerID>***</partnerID>
</securityContext>
</header>
<body>
<bodyContent
xsi:type="java:com.webex.service.binding.ep.GetAPIVersion"/>
</body>
</serv:message>
<<<<<<<< Response follows >>>>>>>>>>
<?xml version="1.0" encoding="UTF-8" ?>
<serv:message xmlns:serv="http://www.webex.com/schemas/2002/06/service"
xmlns:com="http://www.webex.com/schemas/2002/06/common">
<serv:header>
<serv:response>
<serv:result>FAILURE</serv:result>
<serv:reason>Document root element is missing.</serv:reason>
<serv:gsbStatus>PRIMARY</serv:gsbStatus>
<serv:exceptionID>999999</serv:exceptionID></serv:response>
</serv:header>
<serv:body>
</serv:body>
</serv:message>
If I comment out the GetVersion function, the following shows in the Memo:
<<<<<<<<<< Response Follows >>>>>>>>>>
<?xml version="1.0" encoding="UTF-8" ?><message
xmlns="http://www.webex.com/schemas/2002/06/service"><header><response><result>SUCCESS</result><reason>:
WebEx XML API V4.0.9, WebEx XML API V4.1.0, WebEx XML API V3.8.2, WebEx
XML API V4.0.1, WebEx XML API V4.0.5, WebEx XML API V4.2.0, WebEx XML API
V4.0.10, WebEx XML API V3.9.1, WebEx XML API
V4.0.7</reason></response></header><body><bodyContent/></body></message>
> Here's the code that usess the TIdHTTP:
Since the error is coming from the server's valid response, that means you
are sending invalid XML in your request.
> Here's the data in the TMemo field:
Look very carefully at your request data. When you are using GetVersion(),
the "serv" namespace is not being defined anywhere in the request XML, like
it is in the response XML, so your document element is not valid.
Gambit
I would agree with your assessment, however, the following HTML code does
work:
<html><head><title>Test XML API</title>
<script language="javascript">
function submitForm()
{
var url = "http://apidemoeu.webex.com/WBXService/XMLService";
document.form.action = url;
document.form.submit();
}
</script>
</head><body><center><h3>Test XML API</h3>
<form name="form" method="POST" action="">
<b>XML Text:</b><br>
<TEXTAREA NAME="XML" COLS=90 ROWS=30>
<?xml version="1.0" encoding="UTF-8"?>
<serv:message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<header>
<securityContext>
<webExID>**</webExID>
<password>**</password>
<siteID>**</siteID>
<partnerID>**</partnerID>
</securityContext>
</header>
<body>
<bodyContent
xsi:type="java:com.webex.service.binding.ep.GetAPIVersion"/>
</body>
</serv:message>
</TEXTAREA>
<br><br>
<input type="button" value="Test" onclick="submitForm()">
</form></center></body></html>
Regards, Rich
Indy <i>may</i> be encoding you XML in the request.
Is there a way to check, on your server end, the actual
request text? If it has a bunch of < and > in it,
then that's the problem.
What do the GetVersion and FormatXML function do?
Seems it is going to be easier and more reliable for you to use
XMLHTTPRequest.
> I would agree with your assessment, however, the following
> HTML code does work:
That code submits the XML data to the server in a completely different
format than what you are attempting. The equivilent TIdHTTP operation for
that HTML would be to submit a TStringList instead of a TStream, for
example:
var
XMLRequest: TStringList;
XMLResponse : TStringStream;
begin
//...
XMLRequest := TStringList.Create;
try
XMLRequest.Values['XML'] := 'the XML text here';
XMLResponse := TStringStream.Create;
try
HTTP.Post('http://apidemoeu.webex.com/WBXService/XMLService', XMLRequest,
XMLResponse);
// use XMLResponse as needed...
finally
XMLResponse.Free;
end;
finally
XMLRequest.Free;
end;
//...
end;
Gambit
> Indy <i>may</i> be encoding you XML in the request.
When sending a TStream, the request data is not encoded at all. Encoding
only takes place when sending a TStrings instead.
Gambit
> I'm using NativeXML to create the XMLRequest.
We already knew that, but you never showed HOW you are using it to create
the request XML. It doesn't matter at this point, though.
Gambit
[Note: using NativeXML]
Before saving the XML I had set ExternalEncoding the property to use UTF-8
causing some un-needed charcters in the TStream. Removed the
ExternalEncoding property and used EncodingString property (EncodingString
:= 'UTF-8') and problem resolved.
I knew this had to be simple, but was persuing the wrong direction.
Thanks for everyone's help. The comment about encoding is what started me
moving in the right direction.
R