F
fergallydon
I'm retrieving some data from a webservice as follows
Dim RestXML As New Data.DataSet
Dim returnedXML As System.Xml.XmlDataDocument
RestXML.ReadXml(functionURL)
returnedXML = New XmlDataDocument(RestXML)
The return is something like this..
<?xml version="1.0" encoding="utf-8" ?>
- <CallResults>
- <ServiceOutput>
<accountBalance>46.5</accountBalance>
<rentalPrice>3.5</rentalPrice>
<purchasePrice>6.5</purchasePrice>
</ServiceOutput>
- <ServiceResult>
<ResultCode>01</ResultCode>
<ResultAdvisory>message</ResultAdvisory>
</ServiceResult>
</CallResults>
I extract the Result code as follows
strReturncode = returnedXML.DocumentElement.SelectSingleNode("/
CallResults/ServiceResult/ResultCode").InnerText
However with different input parameters to functionURL the XML
returned can be as follows (ServiceOutput is empty)
<?xml version="1.0" encoding="utf-8" ?>
- <CallResults>
<ServiceOutput />
- <ServiceResult>
<ResultCode>00</ResultCode>
<ResultAdvisory>Message</ResultAdvisory>
</ServiceResult>
</CallResults>
In this case there is a failure unless I add "/NewDataSet" to identify
which element I want to extract as follows.
strReturncode = returnedXML.DocumentElement.SelectSingleNode("/
NewDataSet/CallResults/ServiceResult/ResultCode").InnerText
Am I retrieving the response from the web service correctly. How can I
process it so that it works whether ServiceOutput is empty or not.
Thanks for reading.
Dim RestXML As New Data.DataSet
Dim returnedXML As System.Xml.XmlDataDocument
RestXML.ReadXml(functionURL)
returnedXML = New XmlDataDocument(RestXML)
The return is something like this..
<?xml version="1.0" encoding="utf-8" ?>
- <CallResults>
- <ServiceOutput>
<accountBalance>46.5</accountBalance>
<rentalPrice>3.5</rentalPrice>
<purchasePrice>6.5</purchasePrice>
</ServiceOutput>
- <ServiceResult>
<ResultCode>01</ResultCode>
<ResultAdvisory>message</ResultAdvisory>
</ServiceResult>
</CallResults>
I extract the Result code as follows
strReturncode = returnedXML.DocumentElement.SelectSingleNode("/
CallResults/ServiceResult/ResultCode").InnerText
However with different input parameters to functionURL the XML
returned can be as follows (ServiceOutput is empty)
<?xml version="1.0" encoding="utf-8" ?>
- <CallResults>
<ServiceOutput />
- <ServiceResult>
<ResultCode>00</ResultCode>
<ResultAdvisory>Message</ResultAdvisory>
</ServiceResult>
</CallResults>
In this case there is a failure unless I add "/NewDataSet" to identify
which element I want to extract as follows.
strReturncode = returnedXML.DocumentElement.SelectSingleNode("/
NewDataSet/CallResults/ServiceResult/ResultCode").InnerText
Am I retrieving the response from the web service correctly. How can I
process it so that it works whether ServiceOutput is empty or not.
Thanks for reading.