2014-09-22 24 views
1

我對WCF服務非常陌生。我想編寫WCF Web服務,我正在學習以下教程。看來我不能去寫什麼,因爲我得到這個錯誤的所有時間:創建WCF服務時出錯:wcf測試客戶端不支持此操作,因爲它使用的是類型System.Threading

此操作,因爲它使用類型System.Threading沒有在WCF測試客戶端支持..

我創建了帶有默認的代碼如下基本WCF圖書館項目:

IService1.cs

namespace WCFandEFService 
{ 
    [ServiceContract] 
    public interface IService1 
    { 
     [OperationContract] 
     string GetData(int value); 

     [OperationContract] 
     CompositeType GetDataUsingDataContract(CompositeType composite); 
    } 

    [DataContract] 
    public class CompositeType 
    { 
     [DataMember] 
     public bool BoolValue { get; set; } 

     [DataMember] 
     public string StringValue { get; set; } 
    } 
} 

Service1.cs

namespace WCFandEFService 
{ 
    public class Service1 : IService1 
    { 
     public string GetData(int value) 
     { 
      return string.Format("You entered: {0}", value); 
     } 

     public CompositeType GetDataUsingDataContract(CompositeType composite) 
     { 
      if (composite == null) 
      { 
       throw new ArgumentNullException("composite"); 
      } 

      if (composite.BoolValue) 
      { 
       composite.StringValue += "Suffix"; 
      } 

      return composite; 
     } 
    } 
} 

app.config文件:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.serviceModel> 
    <services> 
     <service name="WCFandEFService.Service1"> 
     <host> 
      <baseAddresses> 
      <add baseAddress = "http://localhost:8733/Design_Time_Addresses/WCFandEFService/Service1/" /> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="basicHttpBinding" contract="WCFandEFService.IService1"> 
      <identity> 
      <dns value="localhost"/> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/> 
      <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

按Ctrl-F5它說:您的服務已託管。但是我遇到了錯誤。

這是怎麼發生的?

+0

這是因爲WCF測試客戶端受到嚴重限制。嘗試編寫自己的WCF客戶端並使用該服務 - 這很有可能會起作用。但另一方面:您應該儘量避免傳遞像System.Thread這樣的特定類型 - WCF服務力爭**互操作**,而Ruby或PHP客戶端絕對不會知道如何處理.NET' System.Thread'類型... – 2014-09-22 18:47:13

+0

@marc_s我會盡力,謝謝。其實我正在考慮使用Objective C(iPhone應用程序)中的WCF Web服務。而且,不知道我在哪裏傳遞System.Thread,雖然.. – linda 2014-09-22 19:21:56

回答

相關問題