Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在windows phone中调用webservice和WCF?_C#_Wcf_Web Services_Windows Phone 7 - Fatal编程技术网

C# 在windows phone中调用webservice和WCF?

C# 在windows phone中调用webservice和WCF?,c#,wcf,web-services,windows-phone-7,C#,Wcf,Web Services,Windows Phone 7,我看到了web服务的一种方法,即从MCWebServiceSoapClient调用 //getting the different points for the map when checkbox is checked private void polyc_Checked(object sender, RoutedEventArgs e) { testingwcf.MCWebServiceSoapClient ob = new TestMap.testingwcf.MCWebServic

我看到了web服务的一种方法,即从MCWebServiceSoapClient调用

//getting the different points for the map when checkbox is checked
private void polyc_Checked(object sender, RoutedEventArgs e)
{
    testingwcf.MCWebServiceSoapClient ob = new TestMap.testingwcf.MCWebServiceSoapClient();
    ob.getPolytechnicPointsAsync();
    ob.getPolytechnicPointsCompleted += new EventHandler<testingwcf.getPolytechnicPointsCompletedEventArgs>(ob_getPolyPointsCompleted);
}
//选中复选框时获取地图的不同点
已选中私有void polyc_(对象发送方,路由目标e)
{
testingwcf.MCWebServiceSoapClient ob=newtestmap.testingwcf.MCWebServiceSoapClient();
ob.getPolytechnicPointsAsync();
ob.getPolytechnicPointsCompleted+=新事件处理程序(ob_getPolytechnicPointsCompleted);
}

然而,我要实现的是WCF。如何将此方法转换为WCF?我的周转基金在这里。是否可以从WCF呼叫到windows phone ERI映射?要绘制点?

您想从WP应用程序使用WCF服务吗

首先,通过visual studio生成您的客户端代理,右键单击“引用”,选择“添加服务引用”,选择“转到”按钮,此向导将发现您的服务是否联机

选择高级按钮,然后选择下面的选项

在代码隐藏中,连接到单击事件

private void LoadWebService(object sender, RoutedEventArgs e)
    {
      var service =  new Service1Client();

      service.getRecommendPlaceAsync(new getRecommendPlaceRequest { activityId = 1}); //Provide your id here

      service.getRecommendPlaceCompleted += new EventHandler<MyCloundService.getRecommendPlaceCompletedEventArgs>(RecommendedPlaceRequestComplete);
    }

    void RecommendedPlaceRequestComplete(object sender, MyCloundService.getRecommendPlaceCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            var result = String.Join(",", (from place in e.Result.getRecommendPlaceResult select place.Name).ToArray());

            MessageBox.Show(result);
        }
        else
        {
            MessageBox.Show("An error occured: " + e.Error.Message);
        }
    }
private void LoadWebService(对象发送方,RoutedEventArgs e)
{
var service=new Service1Client();
service.getRecommendPlaceAsync(新getRecommendPlaceRequest{activityId=1});//在此处提供您的id
service.getRecommendPlaceCompleted+=新事件处理程序(RecommendedPlaceRequestComplete);
}
void RecommendedPlaceRequestComplete(对象发送者,MyCloundService.GetRecommendedPlaceCompletedEventArgs e)
{
如果(e.Error==null)
{
var result=String.Join(“,”,(从e.result.getRecommendPlaceResult中的位置选择place.Name.ToArray());
MessageBox.Show(结果);
}
其他的
{
MessageBox.Show(“发生错误:+e.error.Message”);
}
}

看一篇教程

似乎你要做的是从WCF服务在手机上调用一个函数,你不能像那样在电话上使用事件处理程序

由于手机使用电池供电,您可能需要使用推送通知,详情如下: