WCF 新手,具有不想工作的 WCF 服务(我认为是元数据) [英] WCF newbie with a WCF service that doesn't want to work (metadata I think)

查看:24
本文介绍了WCF 新手,具有不想工作的 WCF 服务(我认为是元数据)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这款 WCF 游戏还很陌生,我遇到了一些问题.我将从头开始.

I'm pretty new to this WCF game and I have some problems. I shall start at the beginning.

我根据网上看到的示例设置了 WCF 服务.设置好后,我使用了 Vis Studio 服务测试,一切都很好.图片在这里:

I set up a WCF service from an example I saw online. After I set it up, I used the Vis Studio service test thing and all was good. Image is here:

之后,我按照说明将其作为参考放在 WCF 网站项目中,这是 Vis Studio 2010 中的默认项目类型.按照教程中的指示,我更改了svc 文件到 [dll 名称中的项目].[服务的类名].

After that, I followed the instructions and put it as a reference inside a WCF web site project, which is a default project type in Vis Studio 2010. As directed to in the tutorial, I changed the 'Service' attribute in the svc file to [project in dll name].[class name for service].

当我在这个项目中编辑 WCF 配置"时,它没有像教程中那样为我提供任何服务,所以我想我会自己把它拼凑起来.我打开 web.config 文件并写入以下内容:

When I went to 'edit WCF configuration' in this project, it didn't give me any services as it had done in the tutorial, so I figured I'd piece it together myself. I opened up the web.config file and wrote in the following:

现在我继续将它作为应用程序添加到 IIS.如果我浏览已发布文件夹中的服务,它会将我带到 localhost/[SiteName]/[ServiceName].svc.它告诉我服务的名称,并且我已经创建了所有这些服务.我认为这意味着它到目前为止工作正常.

Now I went on to add this as an application to IIS. If I browse the service in the published folder, it takes me to localhost/[SiteName]/[ServiceName].svc. It tells me the name of the service, and that I have created a service all that. I assume this means it is working correctly so far.

当我尝试在 Silverlight 项目中添加服务引用时出现问题.它问我服务的地址,所以我给它本地主机上的 svc 地址.它说,从地址下载元数据时出错.请验证您输入的地址是否有效".现在我在从 IIS 浏览服务时从地址栏中复制了 svc 路径,所以我认为这是正确的.

The problem comes when I try to add a service reference in a Silverlight project. It asks me for the address of the service, so I give it the svc address on the local host. It says, "There was an error downloading metadata from the address. Please verify that you have entered a valid address". Now I copied the svc path out of the address bar when I browsed the service from IIS, so I assume that's right.

问题是,我是不是遗漏了什么?

Question is, am I missing something?

提前致谢.

推荐答案

您能否在您的服务中的端点元素下方添加以下代码.

Can you add the following code below the endpoint element in your service.

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>

元数据交换需要上述端点.

The above endpoint is needed for metadata exchange.

这篇关于WCF 新手,具有不想工作的 WCF 服务(我认为是元数据)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆