我有一个 Web 服务,它的一种方法可以将 xml 作为字符串接收:
[WebMethod]
public int Catch_string(string str)
{
}
如何从 win 表单将 xml 文件发送到此方法?
为什么不起作用^
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("http://localhost/test/service.asmx");
req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
Stream stm = req.GetRequestStream();
outXml.Save(stm);
stm.Close();
最佳答案
向您的 winforms 应用程序添加 Web 引用,并使用生成的代理类来调用 Web 服务。
看看这个 link了解实现细节。
关于c# - Web服务调用Web方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3757272/