Web services 调用Web服务时传递参数

Web services 调用Web服务时传递参数,web-services,windows-phone-7,Web Services,Windows Phone 7,调用web服务时如何传递参数 我的C#代码是: public部分类CityBlog:PhoneApplicationPage { 字符串str=“”; 公共城市日志() { 初始化组件(); WebClient wc=新的WebClient(); wc.DownloadStringAsync(新Uri(“http://kcspl.in/nadalapp.asmx/GetCityBlog")); wc.DownloadStringCompleted+=新的DownloadStringComplet

调用web服务时如何传递参数

我的C#代码是:

public部分类CityBlog:PhoneApplicationPage
{
字符串str=“”;
公共城市日志()
{
初始化组件();
WebClient wc=新的WebClient();
wc.DownloadStringAsync(新Uri(“http://kcspl.in/nadalapp.asmx/GetCityBlog"));
wc.DownloadStringCompleted+=新的DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
}
void wc_DownloadStringCompleted(对象发送方,DownloadStringCompletedEventArgs e)
{
str=e.Result.Replace(“,”);
str=str.Replace(“,”);
str=str.Replace(“,”);
}

请参阅上面的Uri语句。该Uri是我的web服务链接,
GetCityBlog
是我的web服务类,但在此web服务中,我想添加参数,如
id=1
。如何添加此类参数?

您可以在URL本身中添加参数,也可以将其作为post参数或标题信息添加。您的web服务应该是平等的当Ping发出这样的请求时,你可以阅读这些信息。你可以在Google上搜索关于将参数传递到URL的GET、POST或Header。然后你会找到一个简单的方法。希望这对你的任务有所帮助

public partial class CityBlog : PhoneApplicationPage
{

     string str = "";
    public CityBlog()
    {
        InitializeComponent();

        WebClient wc = new WebClient();
        wc.DownloadStringAsync(new Uri("http://kcspl.in/nadalapp.asmx/GetCityBlog"));
        wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
    }
    void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {

        str = e.Result.Replace("</string>", "");
        str = str.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
        str = str.Replace("<string xmlns=\"http://tempuri.org/\">", "");

    }