Silverlight中的普通WCF

Silverlight中的普通WCF

本文介绍了Silverlight中的普通WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好专家,我是Silverlight的新手,甚至在WCF中也不是很老。但是我在为Silverlight创建普通WCF和WCF时看到了不同。按照以下步骤创建普通WCF时:

右键单击解决方案资源管理器中的Web项目在visual c#WCF服务下添加新项目

它创建三个文件对我来说Iservice(接口)这个的service.svc和service.svc.cs都很好。直到这里。

我理解所有这三个文件的工作。并使用它们甚至通过更改weconfig文件并添加此行
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

我能够使我的WCF也适用于silverlight。

但如果我遵循愚蠢的步骤

右键单击解决方案资源管理器中的Web项目在visual c#silverlight选项卡下添加新项目使用支持Silverlight的WCF服务。

现在我的困惑是使用WCF服务用于Silverlight的方式以及为什么将是另一个的好处和缺点。

Hello Experts,
I am a newbie to silverlight and even not much older in WCF. But I have seen a difference while creating a normal WCF and a WCF for silverlight. When I create a normal WCF by following these steps:

Right click the web project in solution explorer  add new item under visual c# WCF service.

It creates three files for me an Iservice (interface) the service.svc and service.svc.cs of this all is fine till here.

I understand the working of all these three files. And use them even by changing the weconfig file and adding this line
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

I am able to make my WCF work for silverlight too.

But if I follow the foolowing steps

Right click the web project in solution explorer  add new item under visual c# silverlight tab use Silverlight-enabled WCF service.

Then the Iservice file is not created instead the operation contracts are defined in the service.svc.cs file.

Now my confusion is which way to use the WCF service for the silverlight and why what will be the benefits and the drawbacks of the one over the other.

推荐答案

2。它添加了一个svc和一个cs文件。

在cs文件中你可以添加服务功能
从现在开始没有Iservice类了你可以直接添加服务功能service.cs中的服务合同属性

用法取决于要求。

2. It adds a svc and a cs file.

In the cs file you can add the service function
There is no Iservice class from now
U can add the service fuction directly add service contract attribute in service.cs

Usage depends on the requirement.


这篇关于Silverlight中的普通WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:31