我有一个自托管的WebServiceHost,定义如下:
var baseWebHttpBindingBase = "http://localhost:8085/MyService");
var wsEndPoint = new EndpointAddress(baseWebHttpBindingBase);
var binding = new WebHttpBinding();
wsHost = new WebServiceHost(lsWsService, new Uri(baseWebHttpBindingBase));
wsHost.Faulted += new EventHandler(wsHost_Faulted);
wsHost.UnknownMessageReceived += new EventHandler<UnknownMessageReceivedEventArgs>(wsHost_UnknownMessageReceived);
ServiceDebugBehavior sdb = host.Description.Behaviors.Find<ServiceDebugBehavior>();
sdb.IncludeExceptionDetailInFaults = true;
// Mex endpoint
ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
mexBehavior.HttpGetEnabled = true;
wsHost.Description.Behaviors.Add(mexBehavior);
wsHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), baseWebHttpBindingBase + "mex");
wsHost.Open();我已经定义了一个OperationContract:
[OperationContract]
[WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, Method = "PUT", UriTemplate = "/handShake")]
public ConfigSettings handShake(ClientInformationDto clientInfo) {
var configSettings = new ConfigSettings();
// set configSettings values;
return configSettings;
}ConfigSettings有一些杂乱。属性,主要定义为字符串和整数。但是有一个属性被命名为List<ComplexClass>类型的complexClasses -如果complexClasses为null,那么客户端可以很好地使用the服务。但是,如果我填充complexClasses,使用the服务的尝试永远不会完成-在Fiddler中查看它只会显示一个通用的ReadResponse() failed: The server did not return a response for this request.
当我调试代码时,我转到return语句,当我执行最后一步时,Fiddler报告上面的错误。
我知道这个问题与我在configSettings中的ComplexClass有关。该服务继续正常运行,即使在启用Studio的“在所有异常时中断”功能后,也没有发生任何中断。有没有什么方法可以调试返回后发生的任何事情(最有可能是在序列化阶段),这会导致我的服务无法返回任何东西?
发布于 2011-09-22 01:14:10
ComplexClass可能未正确序列化。ComplexClass需要使用序列化属性来公开。
[DataContract]
public class ComplexClass
{
[DataMember]
public string Field { get; set; }
}https://stackoverflow.com/questions/7503290
复制相似问题