Hello Martin. I hope you don't mind, but I've Cc'ed the
wattdepot-users mailing list so others may benefit from the debugging.
You might want to subscribe to the list, it's very low traffic at this
point.
The section of server code that does the check is this:
// Return failure if the SensorData Source doesn't match the uriSource
Source source = dbManager.getSource(uriSource);
if (!source.toUri(server).equals(data.getSource())) {
setStatusMiscError("SensorData payload Source field does not
match source field in URI");
return;
}
From the look of the error message and your Wireshark sniffing, it
appears that the source name is "temp" in both places, as it should
be. I think the problem might be that the server error message doesn't
quite describe the check being performed. The error message says that
the source names don't match, but here I am actually checking that the
whole Source URI contained in the SensorData matches the URI that the
server thinks the Source should have.
Does your wattdepot-server.properties file have a
"wattdepot-server.hostname" property entry? If so, the WattDepot
server will listen on the specified IP address and expect that to be
the canonical form of its URI, but it will also accept requests from
localhost (127.0.0.1). If you are using the hostname property to
listen on a particular IP address, when the server starts up it will
print something like:
2010/02/26 18:25:31 Host: http://server.wattdepot.org:8182/wattdepot/
If you see that, then your client needs to send SensorData objects
that have a source URI that looks like
http://server.wattdepot.org:8182/wattdepot/sources/temp
and not like
http://127.0.0.1:8182/wattdepot/sources/temp
If your server outputs something like this on startup:
2011/05/26 09:39:57 Host: http://127.0.0.1:8182/wattdepot/
then I am still stumped as to what is going on.
In the short term, I will add an issue to change the error message to
be more descriptive by indicating the that source URIs don't match and
actually printing the server's expected Source URI.
Longer term, requiring that SensorData include the Source URI was a
bad design decision stemming from drinking the REST API kool aid.
While there are aspects of RESTfulness in the REST API, it isn't fully
RESTful, yet we still incur the cost of silly things like Source URIs
in the SensorData representation. If I ever get around to a major
rewrite, this kind of thing will be removed, making life easier for
server and client.
Can I ask what project you are using WattDepot for?
--
Robert Brewer
http://excitedcuriosity.wordpress.com/
https://www.facebook.com/kukuicup