WCF服务将不会显示方法

时间:2018-06-21 17:10:42

标签: wcf wcf-data-services

我们在VS2012中创建了WCF服务。该服务有效。所有方法都调用服务工作。

我们遇到的问题是,当我们尝试使用WCF测试客户端加载服务并查看服务方法时。当我们这样做时,会出现如下错误。

使用浏览器加载服务(http://localhost:1234)时,也会出现这些错误,效果很好。但是,当我们单击“ MyService.svc”链接时,也会出现以下错误。

有一次,我们能够通过WCF Test Client测试各个方法。但是由于以下错误,我们现在无法这样做。

尝试查看我们的WCF服务方法时,是什么导致以下错误?

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, 
whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL 
export extension: 
System.ServiceModel.Description.DataContractSerializerOperationBehavior
 contract: http://tempuri.org/:IMyService ----> 
System.Runtime.Serialization.InvalidDataContractException: Type 
'System.Xml.Linq.XDeclaration' cannot be serialized. Consider marking it with 
the DataContractAttribute attribute, and marking all of its members you want 
serialized with the DataMemberAttribute attribute.  If the type is a 
collection, consider marking it with the CollectionDataContractAttribute.  
See the Microsoft .NET Framework documentation for other supported types.
  at
 System.Runtime.Serialization.DataContract.DataContractCriticalHelper
.ThrowInvalid DataContractException(String message, Type type)

at 
System.Runtime.Serialization.DataContract.DataContractCriticalHelper
.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type)

at 
System.Runtime.Serialization.DataContract.DataContractCriticalHelper
.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type 
 type)
  at System.Runtime.Serialization
 .DataContractSet.GetDataContract(Type clrType)
 at System.Runtime.Serialization.DataContractSet
 .GetMemberTypeDataContract(DataMember dataMember)
  at 
 System.Runtime.Serialization.DataContractSet
 .AddClassDataContract(ClassDataContract classDataContract)
  at System.Runtime.Serialization.DataContractSet
  .InternalAdd(XmlQualifiedName 
  name, DataContract dataContract)
  at System.Runtime.Serialization.DataContractSet
 .AddClassDataContract(ClassDataContract classDataContract)
  at System.Runtime.Serialization.DataContractSet
  .InternalAdd(XmlQualifiedName 
  name, DataContract dataContract)
   at System.Runtime.Serialization.DataContractSet.Add(Type type)
   at System.Runtime.Serialization.XsdDataContractExporter.Export(Type type)
   at System.ServiceModel.Description.MessageContractExporter.ExportType(Type 
   type, String partName, String operationName, XmlSchemaType& xsdType)
...   

0 个答案:

没有答案