Web 服务契约操作中的所有参数都不能为空
All parameters in Web Service contract operations cannot be a null
当我向 Web 服务添加一种方法时,在浏览器中打开 WSDL 时出现错误:
All parameters in Web Service contract operations cannot be a null
这里是方法声明:
[<System.ServiceModel.Web.WebInvokeAttribute>]
abstract PostFile: System.IO.Stream -> bool
这是当前的方法实现:
member x.PostFile(stream : Stream) : bool =
let filepath = Path.Combine(System.Environment.CurrentDirectory, "uploadedfile.jpg")
try
let outstream : FileStream = File.Open(filepath, FileMode.Create, FileAccess.Write)
let bufferLen : int = 4096
let buffer : byte array = Array.zeroCreate bufferLen
let count : int = 0
let mutable count = stream.Read(buffer, 0, bufferLen)
if count > 0 then
outstream.Write(buffer, 0, count)
while (count > 0) do
count <- stream.Read(buffer, 0, bufferLen)
outstream.Write(buffer, 0, count)
outstream.Close()
stream.Close()
true
with
| exn ->
printfn "Exception: \n%s" exn.Message
reraise()
这是 full stack from the browser(抱歉,俄语)。
如果我评论这个(而且只有一种方法)一切正常。错误的原因是什么,我该如何解决?
对不起,我发现错误了。需要在合约中设置变量名:
abstract PostFile: stream:System.IO.Stream -> bool
当我向 Web 服务添加一种方法时,在浏览器中打开 WSDL 时出现错误:
All parameters in Web Service contract operations cannot be a null
这里是方法声明:
[<System.ServiceModel.Web.WebInvokeAttribute>]
abstract PostFile: System.IO.Stream -> bool
这是当前的方法实现:
member x.PostFile(stream : Stream) : bool =
let filepath = Path.Combine(System.Environment.CurrentDirectory, "uploadedfile.jpg")
try
let outstream : FileStream = File.Open(filepath, FileMode.Create, FileAccess.Write)
let bufferLen : int = 4096
let buffer : byte array = Array.zeroCreate bufferLen
let count : int = 0
let mutable count = stream.Read(buffer, 0, bufferLen)
if count > 0 then
outstream.Write(buffer, 0, count)
while (count > 0) do
count <- stream.Read(buffer, 0, bufferLen)
outstream.Write(buffer, 0, count)
outstream.Close()
stream.Close()
true
with
| exn ->
printfn "Exception: \n%s" exn.Message
reraise()
这是 full stack from the browser(抱歉,俄语)。
如果我评论这个(而且只有一种方法)一切正常。错误的原因是什么,我该如何解决?
对不起,我发现错误了。需要在合约中设置变量名:
abstract PostFile: stream:System.IO.Stream -> bool