So, I just ended up doing this, Interface:
[OperationContract]
[WebInvoke(Method = "POST",
UriTemplate = "LoggingTest/{logID}/{logLevel}?errorCode={errorCodeInt}",
BodyStyle = WebMessageBodyStyle.Bare)]
void LoggingTest(string logID, string logLevel, int errorCodeInt, Stream message);
Implementation:
public void LoggingTest(string logID, string logLevel, int errorCodeInt, Stream message)
{
switch (logLevel)
{
case "error":
log.Error(errorCodeInt, message, null);
break;
case "warn":
log.Warn(errorCodeInt, message, null);
break;
case "info":
log.Info(errorCodeInt, message, null);
break;
case "debug":
log.Debug(errorCodeInt, message, null);
break;
}
}
And now it works. Must have something to do with the parameters being passed in the UriTemplate, because when I changed it to pass the parameters like so:
UriTemplate = "LoggingTest/{logID}/{logLevel}?errorCode={errorCodeInt}",
it started accepting the POST.
Edit 7/7: Here's the final JavaScript also:
jqueryPost('LoggingTest/LogID/debug?errorCode=0', { message: 'this is a test message'} ;
function jqueryPost(url, message) {
$.post(url, message);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…