Alaska Software Inc. - reading the various fields in an xml doc received using XB2NET?
Username: Password:
AuthorTopic: reading the various fields in an xml doc received using XB2NET?
Nestor G. Torresreading the various fields in an xml doc received using XB2NET?
on Thu, 02 Dec 2010 19:32:54 +0200
Hi can someone help me find an easy way of reading the xml content received 
from a http server.
Please refer to the content.jpg attached for a view of what I get back from 
my service provider http server.
I would like to read ID and Number as per jpg.

Kind regards,
Nestor


Following is the test XB2NET code used:

   oHttp := xbHTTPClient():new()


   cXmlSend:="<WinSMS_Message>"+;
               "<User>nestor@softwareclinic.co.za</User>"+;
               "<Password>9999999</Password>"+;
               "<Message>Hello World</Message>"+;
               "<Schedule>201012020845</Schedule>"+;
               "<Delivery>Yes</Delivery>"+;
               "<Numbers>"+;
                  "<Number>27832620886</Number>"+;
               "</Numbers>"+;
             "</WinSMS_Message>"


   oResult := 
oHttp:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp","POST",cXmlSend)

   cStatus:=var2char(oResult:Content)
   msgbox(cStatus)


Content.jpg
Boris BorzicRe: reading the various fields in an xml doc received using XB2NET?
on Thu, 02 Dec 2010 22:41:15 +0100
Nestor G. Torres wrote in
news:4cede4f5$1342460d$720cc@news.alaska-software.com: 

> Hi can someone help me find an easy way of reading the xml content
> received from a http server.
> Please refer to the content.jpg attached for a view of what I get back
> from my service provider http server.

Use xbXMLDocument instead of xbHTTPClient to send the XML message. The 
:execute() method will return another xbXMLDocument object where you then 
use :GetVar to read it's contents:

Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools
Nestor G. TorresRe: reading the various fields in an xml doc received using XB2NET?
on Fri, 03 Dec 2010 10:18:40 +0200
Hi Boris,

I have tried to do that before as follows and failed:
Note the result is interpreted as NIL and the error code is displayed as 
zero(0)
When I Use the xbHTTPClient it communicates but not with the xbXMLDocument 
...I can not see anything wrong with my code...maybe I can not see the wood 
for the trees?


   oXml:= xbXMLDocument():new()
   oWinSMS_Message := xbComplexType():new("WinSMS_Message")
   oxml:AddVar("WinSMS_Message",oWinSMS_Message)

   oNumbers := xbComplexType():new("Numbers")
   oNumbers:AddVar("Number", "27832620886")

   oWinSMS_Message:AddVar("User", "nestor@softwareclinic.co.za")
   oWinSMS_Message:AddVar("Password", "99999")
   oWinSMS_Message:AddVar("Message", "Hello World")
   oWinSMS_Message:AddVar("Schedule", "201012020845")
   oWinSMS_Message:AddVar("Delivery", "Yes")

   oWinSMS_Message:AddVar("Numbers", oNumbers)

   oResult := oxml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp" )


   If oResult == NIL
          msgbox("Error: "+Str(oxml:ErrorCode))
          msgbox("Error: "+oxml:ErrorSource)
          msgbox("Error: "+oxml:ErrorMessage)
   Else
        cStatus:=var2char(oResult:GetVar())
        msgbox(cStatus)
   Endif

"Boris Borzic" wrote in message 
news:Xns9E42A9C1631B9SQLExpress@87.106.143.233...
> Nestor G. Torres wrote in
> news:4cede4f5$1342460d$720cc@news.alaska-software.com:
>
>> Hi can someone help me find an easy way of reading the xml content
>> received from a http server.
>> Please refer to the content.jpg attached for a view of what I get back
>> from my service provider http server.
>
> Use xbXMLDocument instead of xbHTTPClient to send the XML message. The
> :execute() method will return another xbXMLDocument object where you then
> use :GetVar to read it's contents:
>
> -- 
> Best regards,
> Boris Borzic
>
> http://xb2.net
> http://sqlexpress.net
> industrial strength Xbase++ development tools
Boris BorzicRe: reading the various fields in an xml doc received using XB2NET?
on Fri, 03 Dec 2010 14:50:58 +0100
Try it like this:

cXmlString :="<WinSMS_Message>"+;
               "<User>nestor@softwareclinic.co.za</User>"+;
               "<Password>9999999</Password>"+;
               "<Message>Hello World</Message>"+;
               "<Schedule>201012020845</Schedule>"+;
               "<Delivery>Yes</Delivery>"+;
               "<Numbers>"+;
                  "<Number>27832620886</Number>"+;
               "</Numbers>"+;
             "</WinSMS_Message>"

oXml:= xbXMLDocument():new()
oResult := oXml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp",;
    	cXMLString ) 

? oResult:GetVar()

Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools


Nestor G. Torres wrote in
news:3d5964e3$5748dff3$79024@news.alaska-software.com: 

> I have tried to do that before as follows and failed:
> Note the result is interpreted as NIL and the error code is displayed
> as zero(0)
> When I Use the xbHTTPClient it communicates but not with the
> xbXMLDocument ...I can not see anything wrong with my code...maybe I
> can not see the wood for the trees?
>
Nestor G. TorresRe: reading the various fields in an xml doc received using XB2NET?
on Fri, 03 Dec 2010 16:59:01 +0200
Hi Boris

Tried that and oResult still comes back empty.....maybe I am working on an 
older version than what you currently have?
Release: 3.1.00
2006.05.29

If oResult == NIL
        display message that oResult is empty

&&&&&&&&&&

My current work around:
=================

  oxml := xbHTTPClient():new()

   cXmlSend:="<WinSMS_Message>"+;
               "<User>nestor@softwareclinic.co.za</User>"+;
               "<Password>kczbixer</Password>"+;
               "<Message>Hello World</Message>"+;
               "<Schedule>201012020845</Schedule>"+;
               "<Delivery>Yes</Delivery>"+;
               "<Numbers>"+;
                  "<Number>27832620886</Number>"+;
               "</Numbers>"+;
             "</WinSMS_Message>"

   oResult := 
oxml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp","POST",cXmlSend)

   If oResult == NIL
          msgbox("Error: "+Str(oxml:ErrorCode))    && should be: Error Code: 
999999
          msgbox("Error: "+oxml:ErrorSource)       && should be: Error 
Source: xxxxxxxxx
          msgbox("Error: "+oxml:ErrorMessage)      && should be: Error 
Message: xxxxxx
   Else
        cContent:=var2char(oResult:Content)
        msgbox(cContent)

        oAgent := xbXMLDocument():new(cContent)
        msgbox(oAgent:GetVar({"XMLGateway_Response","NumberID","ID"}))  && 
this works
   Endif

"Boris Borzic" wrote in message 
news:Xns9E435A04FE9FASQLExpress@87.106.143.233...
> Try it like this:
>
> cXmlString :="<WinSMS_Message>"+;
>               "<User>nestor@softwareclinic.co.za</User>"+;
>               "<Password>9999999</Password>"+;
>               "<Message>Hello World</Message>"+;
>               "<Schedule>201012020845</Schedule>"+;
>               "<Delivery>Yes</Delivery>"+;
>               "<Numbers>"+;
>                  "<Number>27832620886</Number>"+;
>               "</Numbers>"+;
>             "</WinSMS_Message>"
>
> oXml:= xbXMLDocument():new()
> oResult := oXml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp",;
>    cXMLString )
>
> ? oResult:GetVar()
>
> -- 
> Best regards,
> Boris Borzic
>
> http://xb2.net
> http://sqlexpress.net
> industrial strength Xbase++ development tools
>
>
> Nestor G. Torres wrote in
> news:3d5964e3$5748dff3$79024@news.alaska-software.com:
>
>> I have tried to do that before as follows and failed:
>> Note the result is interpreted as NIL and the error code is displayed
>> as zero(0)
>> When I Use the xbHTTPClient it communicates but not with the
>> xbXMLDocument ...I can not see anything wrong with my code...maybe I
>> can not see the wood for the trees?
>>
Boris BorzicRe: reading the various fields in an xml doc received using XB2NET?
on Fri, 03 Dec 2010 18:27:45 +0100
Nestor G. Torres wrote in
news:41e7efdc$5b29390b$7e1a9@news.alaska-software.com: 

> Tried that and oResult still comes back empty.....maybe I am working
> on an older version than what you currently have?
> Release: 3.1.00
> 2006.05.29

That is an old version. You may want to consider upgrading.

Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools
Nestor G. TorresRe: reading the various fields in an xml doc received using XB2NET?
on Mon, 20 Dec 2010 05:09:10 +0200
test
"Boris Borzic" wrote in message 
news:Xns9E437EC619AC8SQLExpress@87.106.143.233...
> Nestor G. Torres wrote in
> news:41e7efdc$5b29390b$7e1a9@news.alaska-software.com:
>
>> Tried that and oResult still comes back empty.....maybe I am working
>> on an older version than what you currently have?
>> Release: 3.1.00
>> 2006.05.29
>
> That is an old version. You may want to consider upgrading.
>
> -- 
> Best regards,
> Boris Borzic
>
> http://xb2.net
> http://sqlexpress.net
> industrial strength Xbase++ development tools
Bill SimmethRe: reading the various fields in an xml doc received using XB2NET?
on Thu, 23 Dec 2010 13:53:05 -0500
You might also try setting the XML document object to not "deserialize" the 
response. Then you can examine the HTTP response code and any error message 
being returned.  I had a similar issue with my XML document being slightly 
different than what the server expected. Looking at the HTTP response I 
could get a better idea of what went wrong...

cXmlString :="<WinSMS_Message>"+;
              "<User>nestor@softwareclinic.co.za</User>"+;
              "<Password>9999999</Password>"+;
              "<Message>Hello World</Message>"+;
              "<Schedule>201012020845</Schedule>"+;
              "<Delivery>Yes</Delivery>"+;
              "<Numbers>"+;
                 "<Number>27832620886</Number>"+;
              "</Numbers>"+;
            "</WinSMS_Message>"

oXml:= xbXMLDocument():new( cXmlString )
oXml:deserializeResponse := .F.             return text instead of XML

oResult := oXml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp")

? Var2Char( oResult:statusCode )
? oResult:content

Bill Simmeth
Marshall VA USA

<Boris Borzic> wrote in message 
news:Xns9E435A04FE9FASQLExpress@87.106.143.233...
> Try it like this:
>
> cXmlString :="<WinSMS_Message>"+;
>               "<User>nestor@softwareclinic.co.za</User>"+;
>               "<Password>9999999</Password>"+;
>               "<Message>Hello World</Message>"+;
>               "<Schedule>201012020845</Schedule>"+;
>               "<Delivery>Yes</Delivery>"+;
>               "<Numbers>"+;
>                  "<Number>27832620886</Number>"+;
>               "</Numbers>"+;
>             "</WinSMS_Message>"
>
> oXml:= xbXMLDocument():new()
> oResult := oXml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp",;
>    cXMLString )
>
> ? oResult:GetVar()
>
> -- 
> Best regards,
> Boris Borzic
>
> http://xb2.net
> http://sqlexpress.net
> industrial strength Xbase++ development tools
>
>
> Nestor G. Torres wrote in
> news:3d5964e3$5748dff3$79024@news.alaska-software.com:
>
>> I have tried to do that before as follows and failed:
>> Note the result is interpreted as NIL and the error code is displayed
>> as zero(0)
>> When I Use the xbHTTPClient it communicates but not with the
>> xbXMLDocument ...I can not see anything wrong with my code...maybe I
>> can not see the wood for the trees?
>>
Nestor G. TorresRe: reading the various fields in an xml doc received using XB2NET?
on Fri, 24 Dec 2010 07:12:25 +0200
HI Bill,

What you are proposing may cure the problem, because what seems to be sent 
back is one character indicating success or failure; and I do not think it 
is in html code. I will give this a test later...I really appreciate your 
response.....Have a Merry Christmas and a Happy and prosperous New Year.

Kind Regards,
Nestor

"Bill Simmeth" wrote in message 
news:7f633b55$68534ff$9720@news.alaska-software.com...
> You might also try setting the XML document object to not "deserialize" 
> the response. Then you can examine the HTTP response code and any error 
> message being returned.  I had a similar issue with my XML document being 
> slightly different than what the server expected. Looking at the HTTP 
> response I could get a better idea of what went wrong...
>
> cXmlString :="<WinSMS_Message>"+;
>              "<User>nestor@softwareclinic.co.za</User>"+;
>              "<Password>9999999</Password>"+;
>              "<Message>Hello World</Message>"+;
>              "<Schedule>201012020845</Schedule>"+;
>              "<Delivery>Yes</Delivery>"+;
>              "<Numbers>"+;
>                 "<Number>27832620886</Number>"+;
>              "</Numbers>"+;
>            "</WinSMS_Message>"
>
> oXml:= xbXMLDocument():new( cXmlString )
> oXml:deserializeResponse := .F.             return text instead of XML
>
> oResult := oXml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp")
>
> ? Var2Char( oResult:statusCode )
> ? oResult:content
>
> Bill Simmeth
> Marshall VA USA
>
> <Boris Borzic> wrote in message 
> news:Xns9E435A04FE9FASQLExpress@87.106.143.233...
>> Try it like this:
>>
>> cXmlString :="<WinSMS_Message>"+;
>>               "<User>nestor@softwareclinic.co.za</User>"+;
>>               "<Password>9999999</Password>"+;
>>               "<Message>Hello World</Message>"+;
>>               "<Schedule>201012020845</Schedule>"+;
>>               "<Delivery>Yes</Delivery>"+;
>>               "<Numbers>"+;
>>                  "<Number>27832620886</Number>"+;
>>               "</Numbers>"+;
>>             "</WinSMS_Message>"
>>
>> oXml:= xbXMLDocument():new()
>> oResult := oXml:Execute("http://www.winsms.co.za/api/XMLSendSMS.asp",;
>>    cXMLString )
>>
>> ? oResult:GetVar()
>>
>> -- 
>> Best regards,
>> Boris Borzic
>>
>> http://xb2.net
>> http://sqlexpress.net
>> industrial strength Xbase++ development tools
>>
>>
>> Nestor G. Torres wrote in
>> news:3d5964e3$5748dff3$79024@news.alaska-software.com:
>>
>>> I have tried to do that before as follows and failed:
>>> Note the result is interpreted as NIL and the error code is displayed
>>> as zero(0)
>>> When I Use the xbHTTPClient it communicates but not with the
>>> xbXMLDocument ...I can not see anything wrong with my code...maybe I
>>> can not see the wood for the trees?
>>>
>
>