2

I am currently using NServiceBus6. I am successfully submitting a message from my web api to endpoint which is windows service hosted. Everything works fine in my development environment on my local machine. I am using "NewtonsoftSerializer" in all my endpoint configurations. I have now deployed my solution to a server. My services are now hosted as Window Services as opposed to a console app. Service Insight is now reporting an NServiceBusDeserialization Exception:

An error occurred while attempting to extract logical messages from transport message 8221d498-81ca-406e-8ab6-a77701065f1f ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

A couple items stick out. A. I am not using XmlSerialization. B. I have no serialization issues in development environment. I would appreciate any help provided thank you.

Message Class:

 public class CreateSearchRequest : ICommand
{
    public SearchRequest Request { get; set; }
}

SearchRequest:

 public class SearchRequest : Resource
{
    public string User { get; set; }
    public string SearchName { get; set; }
    public SearchCriteriaSimple Criteria { get; set; }
    public string Status { get; set; }
    public DateTime RequestBegin { get; set; }
    public DateTime RequestEnd { get; set; }
    public int Records { get; set; }
    public string OutputFileName { get; set; }
    public string FtpLocation { get; set; }
    public DateTime CreateDate { get; set; }
}

SearchRequestSimple:

 public class SearchCriteriaSimple
{
    public string Name { get; set; }
    public List<Dictionary<string, string>> Criteria { get; set; }
}

Resource: Azure DocumentDbResource class

William
  • 317
  • 2
  • 12
  • Does it work ok with ServiceControl in your development environment? – Sean Farmar May 19 '17 at 11:02
  • It works as long as I am hosting the NServiceBus endpoint in a console. I installed the endpoint as a windows service and I am now receiving the same error in my development environment – William May 19 '17 at 14:12
  • Can you provide more details (logs), maye send it to support at particular.net and address if to Sean Farmar? – Sean Farmar May 20 '17 at 15:20
  • The serialization exception could be something that happens as a part of the handler code. Could you provide the stacktrace? Why did you choose DocumentDbResource as the base class of your message? From the sound of it, it might cause serialization issues. It is a mixed concern anyways and your messages (a.k.a contracts) should be lean. – Hadi Eskandari Jun 07 '17 at 00:41

1 Answers1

0

I am embarrassed to say. But I have figured out the issue. During development in Visual studio I configured the endpoint in the Task AsyncOnStart() method of ProgramService.cs. It seems once I install the NServiceBus host I must also provide configuration via Endpoint Config. Once I matched serialization there the issues went away.

William
  • 317
  • 2
  • 12