如何做多部分表单数据wcf服务

时间:2012-09-25 14:46:22

标签: c# wcf web-services http-post

如何使用多部分表单数据输入执行wcf服务。我做了一个Web服务,它获取图像的byte []并将其保存在本地路径中并发送url的路径。我已经使用c#windows / web应用程序对此进行了测试,该应用程序工作正常,但是客户端应用程序(如使用Objective c)无法联系服务并发送byte []。因此我切换到wcf服务,我认为可以很容易地做到这一点。顺便说一下我也不太了解wcf ..下面是我在我的wp7应用程序中使用的样本片段。

WebClient webClient = new WebClient();

            webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
            var uri = new Uri("http://localhost/snap/service.asmx/getImages");
            StringBuilder postData = new StringBuilder();
            postData.AppendFormat("&{0}={1}", "EventName", HttpUtility.UrlEncode("sample"));
            postData.AppendFormat("&{0}={1}", "EventVenue", HttpUtility.UrlEncode("chennai"));
            webClient.Headers[HttpRequestHeader.ContentLength] = postData.Length.ToString();
            webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(webClient_UploadStringCompleted);
            webClient.UploadStringAsync(uri, "POST", postData.ToString());

提前致谢...

0 个答案:

没有答案
相关问题