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它说:您的服务已托管。但是我遇到了错误。
这是怎么发生的?
这是因为WCF测试客户端受到严重限制。尝试编写自己的WCF客户端并使用该服务 - 这很有可能会起作用。但另一方面:您应该尽量避免传递像System.Thread这样的特定类型 - WCF服务力争**互操作**,而Ruby或PHP客户端绝对不会知道如何处理.NET' System.Thread'类型... – 2014-09-22 18:47:13
@marc_s我会尽力,谢谢。其实我正在考虑使用Objective C(iPhone应用程序)中的WCF Web服务。而且,不知道我在哪里传递System.Thread,虽然.. – linda 2014-09-22 19:21:56