Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.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/7/wcf/4.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
.net can';t访问wp7中wcf服务的服务引用?_.net_Wcf_Windows Phone 7 - Fatal编程技术网

.net can';t访问wp7中wcf服务的服务引用?

.net can';t访问wp7中wcf服务的服务引用?,.net,wcf,windows-phone-7,.net,Wcf,Windows Phone 7,我正在开发wp7应用程序,其中我必须从网站上获取wcf服务的服务参考 但问题是,当我引用时,它将允许这样做,但服务的客户机类不会显示在项目中&而且它也不允许创建服务合同的客户机对象 以下是我的服务 public class Mobile : IViewUser, IViewCategory { [OperationContract] public void DoWork() { } [OperationContract] public strin

我正在开发wp7应用程序,其中我必须从网站上获取wcf服务的服务参考

但问题是,当我引用时,它将允许这样做,但服务的客户机类不会显示在项目中&而且它也不允许创建服务合同的客户机对象

以下是我的服务

public class Mobile : IViewUser, IViewCategory
{
    [OperationContract]
    public void DoWork()
    {
    }

    [OperationContract]
    public string Test(string data)
    {
        return data;
    }
}
&这是我的web.config设置

<behavior name="Mobile.MobileBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
<service behaviorConfiguration="Mobile.MobileBehavior"       name="BusinessFinder.Web.Services.Mobile">
    <endpoint address="" behaviorConfiguration="webHttp" binding="webHttpBinding"
      contract="BusinessFinder.Web.Services.IMobile" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />      
</service>


请任何人帮助我。

添加服务参考时,单击左下角的“高级”选项卡

选中“始终生成消息契约”

要保存,请取消选择引用程序集中的重用类型

这应该确保您在客户端获得WCF对象

编辑:

再看看你的服务,我觉得有点不对劲

首先需要实现服务合同。这需要一个类似的接口

[ServiceContract]
public interface IMyNewService
{
[OperationContract]
void DoWork()
}
然后您需要实现一个使用该接口的类

public class MyNewService : IMyNewService
试试这个

右键单击服务引用。然后转到配置服务引用。然后取消选中“在引用的程序集中重用类型”复选框。upd


这解决了我的问题,希望它也能帮助其他人

你在哪里寻找“客户服务类”?当您添加服务引用时,它们通常一起在单个文件中生成。