Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
arul
Visitor

XML input and Output

Hi,

How to send the xml input toget the xml as ouput

-Arul
0 Kudos
7 REPLIES 7
Anonymous
Visitor

Re: XML input and Output

Arul,

I'm afraid I don't understand what you're asking. What are you trying to accomplish?
0 Kudos
arul
Visitor

Re: XML input and Output

Hi Patrick,

I am a begginer, the sample application what i tried initally was just to display some posters and click the poster to play video. I used the videoplayer example soure code and modified categories.brs for input xml . I had all other xmls to display Info.
conn.UrlPrefix = "http://rokudev.roku.com/rokudev/examples/videoplayer/xml<-- replaced with my xml directory"
conn.UrlCategoryFeed = conn.UrlPrefix + "/categories.xml<-- replaced with my xml page"

Now i want to try the same thing with webserivce HTTP POST request instead of directly giving the xml soruce as categories.xml. I have webservice which accepts only XML input and returns the categories.xml as ouput.

where can i find the sample code for HTTP Post request
which ifUrlTransfer interface function i have to use for HTTP POST request.

-Arul
0 Kudos
RokuKevin
Visitor

Re: XML input and Output

There is no synchronous roUrlTransfer method for an HTTP Post. Instead, use the asynchronous method AsyncPostFromString() or AsyncPostFromFile() to post the Body.

Example:

url = "<your POST URL>"
body = "<your POST Body>"

obj = CreateObject("roUrlTransfer")
obj.SetPort(CreateObject("roMessagePort"))
obj.SetUrl(url)

timeout% = 1500
num_retries% = 5
str = ""
while num_retries% > 0
if (obj.AsyncPostFromString(body))
event = wait(timeout%, obj.GetPort())
if type(event) = "roUrlEvent"
respCode = event.GetResponseCode()
if respCode = 200 then
return event.GetString()
else
return invalid
end if
elseif event = invalid
obj.AsyncCancel()

obj = CreateObject("roUrlTransfer")
obj.SetPort(CreateObject("roMessagePort"))
obj.SetUrl(url)
timeout% = 2 * timeout%
else
print "roUrlTransfer::AsyncPostFromString(): unknown event"
endif
endif
num_retries% = num_retries% - 1
end while
0 Kudos
ErlyD
Visitor

Re: XML input and Output

Can this method be used to send commands? select home, select up, etc...?

What would it look like?
0 Kudos
hpatel18
Visitor

Re: XML input and Output

Hi,

a) I would like to consume my webservice in my channel. how can i do that?
b) After consuming the web service, i would like to show the data in real time either by using video or by image. is it possible?
0 Kudos
RokuKevin
Visitor

Re: XML input and Output

ErlyD, there is not currently a documented way to send commands to the Roku DVP. There is a way, but we are looking at formalizing a new interface for doing this. Look for more info soon...

hpatel18, You can use the techniques earlier in this thread to consume your web service. You are basically using these components; roUrlTransfer to GET/POST http connections. You will send String xml requests and parse responses using roXMLElement and roXMLList or the BrightScript language XML support.

--Kevin
0 Kudos
saravanainfo
Visitor

Re: XML input and Output

Hi, you said you replaced it with your xml directory, i am trying to do the same... how do i do that?

conn.UrlPrefix = "http://rokudev.roku.com/rokudev/examples/videoplayer/xml<-- replaced with my xml directory"
0 Kudos