我想從我的Silverlight 3應用程序調用WCF服務。 但是...當試圖在我的web項目中創建'啓用silverlight的wcf服務'時,我的VS2008在創建項目時(我認爲在編輯web.config時)崩潰。'正常'SVC與'Silverlight'SVC(WCF)
所以我想:讓我們創建一個'普通'wcf服務,並手動將其編輯爲'啓用silverlight的web服務'。
所以我想知道有什麼區別,第二:爲什麼從Silverlight應用程序調用的服務和非Silverlight應用程序之間存在差異?
這是我現在有一個綁定(無我有一個接口協議的業務,恰恰暴露了直接的班,開始):
<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應用程序添加引用它,我得到的消息:
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
(PS,該服務可以在瀏覽器啓動時,我得到這個:
svcutil.exe http://localhost:9599/GetNewData.svc?wsdl
)