2010-09-21 159 views
2

我有一个方法,web服务,其临危XML作为字符串:Web服务调用的Web方法

[WebMethod] 
public int Catch_string(string str) 
{ 
} 

我怎么能发送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(); 
+2

为什么不使用Visual Studio生成Web服务代理(添加Web引用)并以这种方式调用Web服务? – 2010-09-21 04:22:29

+0

我添加了对web服务的引用,下一步是什么?并没有说这个网络方法保存这个文件在服务器上,顺便说一句。 – eba 2010-09-21 04:32:32

回答

4

添加Web引用到你的WinForms应用程序,并使用生成的代理类来调用web服务。

检出此link的实施细节。

+0

sry。解决了我的问题/ thx所有 – eba 2010-09-21 04:36:23