According to the SDK the responseXML property returns an
IDispatch, but this has no obvious use in parsing XML. I tried
casting this to a DOMDocument30 interface and querying the xml
property but nothing was returned.
My question is this: does anyone know what this property should
be cast to and how to use it.
Thanks
Alex
Thanks for the reply.
> Isn't DOMDocument30 part of the new MSXML3.DLL? IXMLHTTPRequest was
> replaced in that library with just IXMLHTTP.
I am using msxml3.dll for the interfaces and the xmlsdk30.chm help file for
reference.
There is no IXMLHTTP but there is an XMLHTTP which is just a redefinition of
IXMLHTTPRequest.
> If you're using IXMLHTTPRequest, then a document is just IXMLDOMDocument,
I think.
> I haven't tried it...I always just use another DOM object and call
loadXML
> on it using the responseText as the parameter. Then I can manipulate that
> DOM object's XML however I like.
> -Howard
I have also tried the loadXML, which works fine, but it seemed that if the
HTTPRequest
object had already parsed the XML it would be silly to parse it a second
time in another
DOM object, that is why I was hoping for information on how to use it. I
also assumed
that it would be an IXMLDocument, but casting it to that produced no
meaningful result.
Alex
Here's an example that uses XMLHTTP and demos how responseXML is used.
It's an old example that compiles under D4/D5, but the interfaces are the
same...
HTH
--Craig
procedure TfrmSOAP.btnExecuteClick(Sender: TObject);
var soapRequest,
soapResponse : DOMDocument;
httpOb : IXMLHTTPRequest;
nodeEnvelope,
nodeBody,
nodeMethod : IXMLDOMNode;
smn, s : string;
sServer : String;
bStrMethod, bstrUrl, varASync, bStrUser, bStrPassword : OleVariant;
sXML : String;
begin
//sServer := 'http://localhost/echoTest.asp';
if cbEndpoint.Checked then
sServer := edit7.text
else
sServer := 'http://localhost/soap/calcxslt.asp';
bStrMethod := 'POST';
bstrUrl := sServer;
varAsync := false;
bStrUser := '';
bStrPassword :='';
httpOb := CoXMLHTTP.Create; //CreateObject("Microsoft.XMLHTTP");
httpOb.Open(bStrMethod, bstrUrl, varASync, bStrUser, bStrPassword);
s:= '<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope">';
s:=s+'<SOAP-ENV:Body>';
s:=s+' <m:' + edtMethod.Text +'
xmlns:m="uuid:361C5CDE-FC66-4B17-A2C1-EB221DEFFD66">';
s:=s+' <pt1>';
s:=s+' <x>'+edit3.text+'</x>';
s:=s+' <y>'+edit4.text+'</y>';
s:=s+' </pt1>';
s:=s+' <pt2>';
s:=s+' <x>'+edit5.text+'</x>';
s:=s+' <y>'+edit6.text+'</y>';
s:=s+' </pt2>';
s:=s+' </m:' + edtMethod.Text +'>';
s:=s+'</SOAP-ENV:Body>';
s:=s+'</SOAP-ENV:Envelope>';
// Prepare the http request header...
httpOb.setRequestHeader('Content-Type','text/xml');
smn := 'uuid:361C5CDE-FC66-4B17-A2C1-EB221DEFFD66#';
smn := smn + edtMethod.Text;
httpOb.setRequestHeader ( 'SOAPAction', smn );
mRequest.text:=s;
// Send the request...
httpOb.send(s);
mResponse.text:=httpOb.ResponseText;
// Process the response...
soapResponse := CoDOMDocument.Create;
soapResponse.async:=false;
soapResponse.Load(httpOb.ResponseXml);
nodeEnvelope := soapResponse.childNodes[1];
nodeBody := nodeEnvelope.firstChild;
nodeMethod := nodeBody.firstChild;
if nodeMethod.baseName <> 'Fault' then begin
edit1.text:=nodeMethod.firstChild.selectSingleNode('x').text;
edit2.text:=nodeMethod.firstChild.selectSingleNode('y').text;
end;
end;
I have tried this and it does not seem to work properly. In my test project
I
have an object called http which is an IXMLHTTPRequest and doc which
is a DOMDocument30. Once I have done http.send('') the
http.responseText contains valid xml. If I do
doc.loadXML(http.responseText)
I get a result of true and the doc contains my xml document. However, if I
try doc.load(http.responseXML) I get a result of false and the
doc.parseError.reason gives the following: "XML document must have a top
level element."
So the question now is, why is it that loadXML works with the responseText
property, but load does not work with the responseXML property?
My response definitely has a top level element, so the only thing I can
think
that might (but shouldn't) cause a problem is the "<?xml version='1.0' ?>"
"Craig Murphy" <cr...@isleofjuraDOTdemon.co.uk> wrote in message
news:3b88407a_1@dnews...
Have you set the Content-Type for the response?
Rgs
--Craig