I've got a self-hosted WebServiceHost
defined like so:
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();
I've got an OperationContract
defined:
[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 has some misc. properties, mostly defined as strings and ints. There's one property though that is named complexClasses of type List<ComplexClass>
- if complexClasses is null, then the client can consume开发者_开发技巧 the webservice just fine. However, if I populate complexClasses, the attempt to consume the webservice never completes - watching it in Fiddler just shows a generic ReadResponse() failed: The server did not return a response for this request.
When I debug the code, I get to the return statement and when I do the final step out, Fiddler reports to above error.
I know the problem is related to my ComplexClass in configSettings. The service continues to run just fine, and even after enabling Studio's "break on all exceptions" feature nothing ever breaks. Is there anyway to debug whatever happens after returning (most likely in the serialization stage) that is causing my service to fail to return anything?
It is possible that ComplexClass is not serialized properly. ComplexClass needs to be exposed with Serialization attributes.
[DataContract]
public class ComplexClass
{
[DataMember]
public string Field { get; set; }
}
精彩评论