Web Service Connection: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
No edit summary
No edit summary
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
To connect to the Web Service, J. River recommends the following flow. Please note that [[Gizmo]] uses a similar approach.
To connect to the [[Web Service Interface]], JRiver recommends the following flow. Please note that [[Gizmo]] uses a similar approach.


* Ask the user for an Access Key.
'''Ask the user for an access key'''


An Access Key will be six case-sensitive letters. No digits or symbols are used.
An access key will be six case-sensitive letters. No digits or symbols are used.


'''Lookup server addresses from access key'''

Call the web service (replace [Access Key] with the actual access key):<br />
http://webplay.jriver.com/libraryserver/lookup?id=[Access Key]

It is recommended that you use a short timeout.


'''Optionally wake computers'''

Loop the IP addresses returned and send a wake request to each MAC address returned. The details of creating magic packets for wake requests is beyond the scope of this document. For Java code, this might help: http://www.jibble.org/wake-on-lan/


'''Try connecting to each IP address'''

Loop the IP addresses returned, and attempt to connect to:
http://[Returned IP Address]:[Returned Port]/MCWS/v1/Alive

Be sure to loop the addresses in order so that you first attempt to connect on the LAN and only fallback to the WAN if necessary.

Use a short timeout, usually 2 to 5 seconds.

Parse the response and make sure the access key matches the access key entered by the user.

Also, check the library version and program version as necessary.


'''Authenticate'''

Call the web service function:
MCWS/v1/Authenticate

Provide the saved username and password if you have one.

If authentication does not succeeed, ask the user for their username and password. Then repeat.

Store the token returned and include it in all future calls.


'''Use MCWS'''

You can start using the web service at this point. Include the token in each call using &Token=[Token Received During Authentication].


'''Tips'''

Most all web service responses use the same XML response format. Create a single object to represent the response you can use for all calls.

Latest revision as of 23:24, 10 May 2014

To connect to the Web Service Interface, JRiver recommends the following flow. Please note that Gizmo uses a similar approach.

Ask the user for an access key

An access key will be six case-sensitive letters. No digits or symbols are used.


Lookup server addresses from access key

Call the web service (replace [Access Key] with the actual access key):
http://webplay.jriver.com/libraryserver/lookup?id=[Access Key]

It is recommended that you use a short timeout.


Optionally wake computers

Loop the IP addresses returned and send a wake request to each MAC address returned. The details of creating magic packets for wake requests is beyond the scope of this document. For Java code, this might help: http://www.jibble.org/wake-on-lan/


Try connecting to each IP address

Loop the IP addresses returned, and attempt to connect to: http://[Returned IP Address]:[Returned Port]/MCWS/v1/Alive

Be sure to loop the addresses in order so that you first attempt to connect on the LAN and only fallback to the WAN if necessary.

Use a short timeout, usually 2 to 5 seconds.

Parse the response and make sure the access key matches the access key entered by the user.

Also, check the library version and program version as necessary.


Authenticate

Call the web service function: MCWS/v1/Authenticate

Provide the saved username and password if you have one.

If authentication does not succeeed, ask the user for their username and password. Then repeat.

Store the token returned and include it in all future calls.


Use MCWS

You can start using the web service at this point. Include the token in each call using &Token=[Token Received During Authentication].


Tips

Most all web service responses use the same XML response format. Create a single object to represent the response you can use for all calls.