NetTalk Central

Author Topic: Serving a xml with a NetWebSource are adding some lines  (Read 5666 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Serving a xml with a NetWebSource are adding some lines
« on: May 23, 2015, 06:28:59 AM »
Hi
I use xFiles to make an XML I need to serve.
I use a NetWebSource proc to do it.
The xml is ok but when you get the page with a browser, the NteTalk server adds 2 lines at the end of the xml like:

> <?xml version="1.0" encoding="ISO-8859-1"?>
> <file>
>   <item>
>     <STOCK>AAPL</STOCK>
>     <CURRENCY>PES</CURRENCY>
>   </item>
> </file>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <ajax-response></ajax-response>


My Code: (vCotiza is a view)

        open(vCotiza)
        set(vCotiza)
        x.save(vCotiza)   
        packet.Append(x.XmlData)
        ! if you look at the packet.getValue() it is OK, without the last two lines
        p_web.ParseHTML(packet,1,0,NET:NoHeader)

You can test it browsing the url:
http://200.68.94.242/xmloc?F=Sxml&S=L&M=PES&Z=1&ES=APBR,ERAR

How can I solve it?
Thanks
-----------
Regards
Alberto

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #1 on: May 24, 2015, 05:12:48 PM »
Try moving your code into just a normal source procedure not a websource procedure.

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #2 on: May 25, 2015, 04:59:42 AM »
Thanks Kevin,
I've donde this but now the proc is unaccessible trought a browser

The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

It seams tha,t if the proc is not a NetWebSource, the Webhandler does not recognice it.

TThen, I've tride to call the source proc from the old NetWebSource with:

    CODE
        xmloc(p_web)  !call the source proc
        RETURN         !return doing nothing with the NetWebSource
    omit('!***')     

and the result is the same, NT adds the two lines at the bottom.

I have an old proc that do not use xfiles, it just make a page with data separated by <13,10>, and also in this case NT adds that two lines...

208.150
0
22/05/2015
#0
</data>
<?xml version="1.0" encoding="iso-8859-1"?>
<ajax-response></ajax-response>


You can test it browsing the url:
http://200.68.94.242/xoc?F=S&S=L&M=PES&Z=1

Any Idea?

« Last Edit: May 25, 2015, 05:15:50 AM by michelis »
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #3 on: May 25, 2015, 05:41:54 AM »
what embed do you have this in? I recommend

"Processed Code"

>>        x.save(vCotiza)   

I presume x is an xFiles object?
if so
x.OmitXMLHeader = true

cheers
Bruce




Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #4 on: May 25, 2015, 06:10:10 AM »
Yes Bruce...

ProcecedCode:

My Code:
(vCotiza is a view)
(x is a xFiles object)

        open(vCotiza)
        set(vCotiza)
        x.save(vCotiza)   
        packet.Append(x.XmlData)
        ! if you look at the packet.getValue() it is OK, without the last two lines
        p_web.ParseHTML(packet,1,0,NET:NoHeader)

If I use x.OmitXmlHeader it is worst, the page does not have the xml header and the two lines still added at the bottom.

This two lines are added at the bottom by NT
<?xml version="1.0" encoding="iso-8859-1"?>
<ajax-response></ajax-response>

May be trought the   p_web.ParseHTML(packet,1,0,NET:NoHeader)   proc???

Check this, with a xml made by xFiles:
http://200.68.94.242/xmloc?F=Sxml&S=L&M=PES&Z=1&ES=APBR,ERAR
and this, with plain data separated by 13,10:
http://200.68.94.242/xoc?F=S&S=L&M=PES&Z=1

in both cases NT add this two lines.

Thanks







-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #5 on: May 25, 2015, 06:18:28 AM »
I´ve added two messages in the ParseHtml in the Webhandler proc like:

p_web.ParseHTML PROCEDURE(StringTheory p_Buffer,long p_DataStart=1,long p_DataEnd=0,Byte p_Header=NET:SendHeader)

  CODE
  message(p_buffer.getvalue())
  PARENT.ParseHTML(p_Buffer,p_DataStart,p_DataEnd,p_Header)
  message(p_buffer.getvalue())

When I fetch the page I get 4 messages
The first 2 before and after the   PARENT.ParseHTML are ok withot the last two lines

but...
Then comes two more message with exactly this two lines!!!

Its like after my proc calls the  ParseHTML, then another proc calll it adding the two lines.

Hope this helps




-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #6 on: May 25, 2015, 06:26:59 AM »
If I add code to the Webhandler like:

p_web.ParseHTML PROCEDURE(StringTheory p_Buffer,long p_DataStart=1,long p_DataEnd=0,Byte p_Header=NET:SendHeader)
  CODE
        if instring('<ajax-response></ajax-response>',p_buffer.getvalue(),1,1)=0

  PARENT.ParseHTML(p_Buffer,p_DataStart,p_DataEnd,p_Header)

        end

All is OK.

Hope this helps.

-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #7 on: May 25, 2015, 06:38:47 AM »
Hi Alberto,

I think you are doing this very wrong - and certainly your fix in WebHandler  will probably cause problems elsewhere.

I recommend you post an example app of your original problem so I can see what you are doing, and give you the correct fix.

cheers
Bruce


Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #8 on: May 25, 2015, 07:14:29 AM »
ok Bruce,

I attached a zip with the sln, app, dct, etc for you tu compile and test.

I remove the WebHandler change.

The offending proc is "xmloc"

Just fetch:

http://yourIP/xmloc?F=Sxml&S=L&M=PES&Z=1&ES=APBR,ERAR

Thank you very much.

[attachment deleted by admin]
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #9 on: May 26, 2015, 12:03:07 AM »
hi Alberto,

1) first thing - this should be in a NetWebPage, not a netWebSource. A netWebSource is designed to be embedded on a page, and you are calling it as a URL. So move it to a NetWebPage

2) Set the NetWebPage to "Page Type: XML" and turn off "Add <?xml Version..."

3) embed your code in the NetWebPahe in the embed point between
do Header
and
do Footer

4) remove the RETURN from your code.

5) remove the call to p_web.ParseHTML(packet,1,0,NET:NoHeader) from your code.

cheers
Bruce


Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Serving a xml with a NetWebSource are adding some lines
« Reply #10 on: May 26, 2015, 04:14:43 PM »
Thanks Bruce, that did the trick.
-----------
Regards
Alberto