webmethod with optional C# arguments appear to be required when invoked as a RESTful URI - gives InvalidOperationException: Missing parameter
I have a webmethod which works and I've added some optional parameters (because I don't want to burden all callers with providing these values; they are primarily for my development needs since my webmethod constructs a diagnostic EventLog.WriteEntry):
[WebMethod(Description = "DownloadFile method for ASP.Net clients")]
public void DownloadFileCF(string trimURL, string TrimRecordNumber
, string CallerPC = "not specified"
, string RequestorID = "not specified")
I can also call the above method with a RESTful URI like this: http://localhost/sdkTrimFileServiceASMX/FileService.asm开发者_如何学编程x/DownloadFileCF?trimURL=60~GROUPER~1137&TrimRecordNumber=5
but then I get this:
System.InvalidOperationException: Missing parameter: CallerPC.
at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.UrlParameterReader.Read(HttpRequest request)
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
Yet when I test the webmethods of the webservice on localhost and supply values for only the first 2 textboxes and click INVOKE button, then the arguments are treated as optional.
I am VERY brand new to REST rules. Can someone straighten me out on this?
精彩评论