首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >“普通”SVC与“Silverlight”SVC (WCF)

“普通”SVC与“Silverlight”SVC (WCF)
EN

Stack Overflow用户
提问于 2010-04-27 16:21:21
回答 2查看 518关注 0票数 0

我正在尝试从我的Silverlight 3应用程序调用WCF服务。但是..。当试图在我的web项目中创建一个“启用silverlight的wcf服务”时,我的VS2008在创建项目的过程中崩溃了(我想是在编辑web.config的时候)。

所以我想:让我们创建一个“普通的”wcf服务,并手动将其编辑为“支持silverlight的webservice”。

所以我想知道它们的区别是什么,第二:为什么从silverlight应用程序调用的服务与非silverlight应用程序调用的服务之间存在差异?

这就是我现在拥有的绑定(我有一个没有接口契约的服务,首先只公开了一个直接的类):

代码语言:javascript
复制
<system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="RadControlsSilverlightApp1.Web.GetNewDataBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <bindings>
            <customBinding>
                <binding name="customBinding0">
                    <binaryMessageEncoding />
                    <httpTransport />
                </binding>
            </customBinding>
        </bindings>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <services>
            <service behaviorConfiguration="RadControlsSilverlightApp1.Web.GetNewDataBehavior"
             name="RadControlsSilverlightApp1.Web.GetNewData">
                <endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
                 contract="RadControlsSilverlightApp1.Web.GetNewData" />
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>

    </system.serviceModel>

这个方法不起作用,因为当我从silverlight应用程序中添加对它的引用时,我会收到以下消息:

代码语言:javascript
复制
Warning 2   Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Exception has been thrown by the target of an invocation.
XPath to Error Source: //wsdl:definitions[@targetNamespace='']/wsdl:portType[@name='GetNewData']    C:\Silverlight\RadControlsSilverlightApp1\RadControlsSilverlightApp1\Service References\ServiceReference1\Reference.svcmap  1   1   RadControlsSilverlightApp1
Warning 3   Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='']/wsdl:portType[@name='GetNewData']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='CustomBinding_GetNewData']    C:\Silverlight\RadControlsSilverlightApp1\RadControlsSilverlightApp1\Service References\ServiceReference1\Reference.svcmap  1   1   RadControlsSilverlightApp1
Warning 4   Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='CustomBinding_GetNewData']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='GetNewData']/wsdl:port[@name='CustomBinding_GetNewData']  C:\Silverlight\RadControlsSilverlightApp1\RadControlsSilverlightApp1\Service References\ServiceReference1\Reference.svcmap  1   1   RadControlsSilverlightApp1
Warning 5   Custom tool warning: No endpoints compatible with Silverlight 3 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.  C:\Silverlight\RadControlsSilverlightApp1\RadControlsSilverlightApp1\Service References\ServiceReference1\Reference.svcmap  1   1   RadControlsSilverlightApp1

(另外,该服务可以在浏览器中启动,我得到的信息是:

代码语言:javascript
复制
svcutil.exe http://localhost:9599/GetNewData.svc?wsdl

)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-05-26 19:24:28

似乎手头还有另一个问题,这里有答案。

can i use a generic list in a WCF called from silverlight?

票数 0
EN

Stack Overflow用户

发布于 2010-04-28 00:41:29

主要为您做的是:

代码语言:javascript
复制
Web.config is configured to use basicHttpBinding since Silverlight does not support ws*. 
ASP compatibility mode: <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 

因此,一个好的开始应该是将您的服务转换为使用basicHttpBinding。有关适用于服务的web.config部分的更多信息,请查看Configuring Services Using Configuration Files

在使用Silverlight enabled WCF Service Template is Bad Practice中描述的模板时,可能会失去一些灵活性

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2719695

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档