umeshchand1507 / upnpx

Automatically exported from code.google.com/p/upnpx
0 stars 0 forks source link

SoapAction parameters are not order preserved #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Thanks to opensource the project and change the license to BSD!

I tried the latest svn and found out it doesn't work with Windows 7 media 
player's media sharing(Windows Xp not tested yet). It founds the media server, 
but when it trys to do the ContentDirectory browse, I always get a 402 Invalid 
Args error.

It works for Twonky server thou.

I spent some time in tracing the issue and found out it is the SoapAction 
paramenter is not passing to the server in "proper" order. The xml body tags 
for ContentDirectory:1 Browse SoapAction is in the order:
BrowseFlag ObjectID SortCriteria Filter StartingIndex RequestedCount.

When I tried hard coded the order in:
ObjectID BrowseFlag Filter StartingIndex RequestedCount SortCriteria

Then I am getting the contents list from windows's upnp server.

I checked the code:
trunk/src/upnp/SoapActionsContentDirectory1.m
line 88:
parameterKeys = [NSArray arrayWithObjects:@"ObjectID", @"BrowseFlag", 
@"Filter", @"StartingIndex", @"RequestedCount", @"SortCriteria", nil];

The parameters are setup in a proper order, But they are stored in NSDictionary 
which is not order preserved so the output order would vary depends on the hash 
algorithm, I guess.

I read other upnp implementation, some are using the vector with pair value to 
preserve the order. But it might be to much work for the project. Maybe an 
ordered dictionary should be used to replace the NSDictionary to have the issue 
sorted in a relatively easy way.

Original issue reported on code.google.com by vixvix...@gmail.com on 12 Jul 2011 at 6:15

GoogleCodeExporter commented 9 years ago
I used an ordered dictionary implementation presented here:
http://cocoawithlove.com/2008/12/ordereddictionary-subclassing-cocoa.html

Replace the parameters using in SoapAction*.m and now the library/demo works 
for windows media share as well.

Original comment by vixvix...@gmail.com on 13 Jul 2011 at 1:51

GoogleCodeExporter commented 9 years ago
Reproduced on Windows 7 Ultimate.

2011-07-14 08:57:36.426 upnpxdemo[94205:207] Server Staus Code=500
2011-07-14 08:57:36.426 upnpxdemo[94205:207] Request=<?xml version="1.0" 
encoding="utf-8"?><s:Envelope 
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:Browse 
xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1"><BrowseFlag>BrowseDire
ctChildren</BrowseFlag><ObjectID>0</ObjectID><SortCriteria>+dc:title</SortCriter
ia><Filter>*</Filter><StartingIndex>0</StartingIndex><RequestedCount>0</Requeste
dCount></u:Browse></s:Body></s:Envelope>
2011-07-14 08:57:36.427 upnpxdemo[94205:207] Response=<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Bod
y><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>UPnPError</
faultstring><detail><u:UPnPError 
xmlns:u="urn:schemas-upnp-org:control-1-0"><u:errorCode>402</u:errorCode><u:erro
rDescription>Invalid 
Args</u:errorDescription></u:UPnPError></detail></SOAP-ENV:Fault></SOAP-ENV:Body
></SOAP-ENV:Envelope>
2011-07-14 08:57:36.428 upnpxdemo[94205:207] Parser Error 5, Description: 
(null), Line: 1, Column: 1

Original comment by bruno.ke...@gmail.com on 14 Jul 2011 at 1:00

GoogleCodeExporter commented 9 years ago
Thanks for the good feedback.

Original comment by bruno.ke...@gmail.com on 17 Jul 2011 at 2:21