当我向Web服务添加一个方法时,我在浏览器中打开WSDL时遇到错误:
Web服务合同操作中的所有参数都不能为空
这是方法声明:
[<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(对不起,俄语)。
如果我评论这个(并且只有一种方法),一切正常。错误的原因是什么?如何解决?
答案 0 :(得分:1)
抱歉,我发现了错误。有必要在合同中设置变量名称:
abstract PostFile: stream:System.IO.Stream -> bool