public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData) { string data = inputData.ReadToEnd(); // this is where the POST requests are handled, regardless of the actual URL // step 1: find out which SMAPI method is called by taking a look at the SOAPACTION Header if (p.httpHeaders.ContainsKey("SOAPACTION")) { // we got a SOAPACTION key, now retrieve it String rawSOAPACTION = (String)p.httpHeaders ["SOAPACTION"]; // the SOAPACTION header will be in this format: // SOAPACTION: "http://www.sonos.com/Services/1.1#$command" // // we only have to filter it for the #$command part String SOAPACTION = rawSOAPACTION.Remove(0, rawSOAPACTION.LastIndexOf("#") + 1); SOAPACTION = SOAPACTION.Remove(SOAPACTION.Length - 1); //ConsoleOutputLogger.WriteLine (SOAPACTION.ToUpper ()); String SMAPIAnswer = ""; switch (SOAPACTION.ToUpper()) { case "GETLASTUPDATE": //ConsoleOutputLogger.WriteLine ("GetLastUpdate called"); SMAPIAnswer = SMAPI.GetLastUpdate(xsnCurrentData, data); break; case "GETMETADATA": //ConsoleOutputLogger.WriteLine("getMetadata called"); SMAPIAnswer = SMAPI.getMetadata(xsnCurrentData, data); break; case "GETMEDIAMETADATA": //ConsoleOutputLogger.WriteLine ("getMediaMetadata called"); SMAPIAnswer = SMAPI.getMediaMetadata(xsnCurrentData, data); break; case "GETMEDIAURI": //ConsoleOutputLogger.WriteLine ("getMediaURI called"); SMAPIAnswer = SMAPI.getMediaURI(xsnCurrentData, data); break; default: //ConsoleOutputLogger.WriteLine ("Unknown: " + SOAPACTION); break; } if (SMAPIAnswer.Length > 0) { // we got an answer from the SMAPI handlers, pipe it out p.writeSuccess("Content-Type: text/xml; charset=utf-8"); p.outputStream.WriteLine(SMAPIAnswer); } else { p.writeFailure(); } } else { p.writeFailure(); } }