在wcf restful服务上打开xml文件并转换为类对象

时间:2014-04-16 12:04:33

标签: c# xml windows-8

我是 wcf restful service的新手。我想将XML文件从Windows 8商店应用程序传递到 wcf restful service并在服务上打开该文件以保存数据。 ..请帮帮我......

public async void UPLOADFILE(string zipfile)
{
    StorageFile file1 = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(zipfile);
    HttpClient httpClient = new HttpClient();
    MultipartFormDataContent MFDcontent = new MultipartFormDataContent("-WINDOWS8-APP");

    using (IRandomAccessStream writeStream = await file1.OpenAsync(FileAccessMode.ReadWrite))
    {

        Stream stream = writeStream.AsStreamForWrite();
        HttpContent content = new ByteArrayContent(ReadToEnd(stream));
        content.Headers.Add("Content-Disposition", "form-data; name=\"orderFile\"; filename=\"" + zipfile + "\"");
        content.Headers.Add("Content-Type", "application/xml");
        MFDcontent.Add(content);
        string resourceAddress ="http://localhost:33434/Service1.svc/Book/"+zipfile ;
        HttpResponseMessage response = await httpClient.PostAsync(resourceAddress, MFDcontent);

    }
}

0 个答案:

没有答案