问题描述
我已经构建了一个 WCF 服务来接受一个文件并将其写入磁盘.前端由一个带有 SWFUpload 的页面组成,该页面在客户端处理上传.显然,SWFUpload 发布的数据的内容类型为:multipart/form-data.
I've build a WCF Service to accept a file and write it to disk. The front-end consists of a page with SWFUpload which is handling the upload on the client side. Apparently, SWFUpload posts the data with a Content Type of: multipart/form-data.
我认为这没问题,但在服务端我收到一个错误.错误是ProtocolException",需要 text/xml.我在绑定中尝试了不同的消息编码,但似乎没有任何效果.
I would think this ok but on the Service side I get an error. The error is "ProtocolException" expecting text/xml. I've tried different message encodings in the bindings but nothing seems to work.
如何使用 multipart/form-data 上传此文件?
How can I get this file uploaded using multipart/form-data?
推荐答案
@jdiaz,
@JasonS 是对的,要上传文件,您需要将其作为字节流传输.您需要使用 WCF 流式传输.例如,关于如何通过 WCF 上传文件,请参见 an文章来自http://kjellsj.blogspot.com
@JasonS is right, to upload file you need to transfer it as a byte stream. You need to use WCF streaming. For example on how to upload file via WCF see an article from http://kjellsj.blogspot.com
这篇关于如何将文件上传到 WCF 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!