WFC Contract in separate assembly

Posted on 2009-04-24
Last Modified: 2013-11-10
When I move my data contract member to a new assembly I get the following error:

Unable to deserialize XML body with root name 'NotificationRequest' and root namespace '' (for operation 'SendNotification' and contract ('NotificationService',  '')) using DataContractSerializer. Ensure that the type corresponding to the XML is added to the known types collection of the service.

I have already changed the assembly tag in my service, but it still does not work.  I am exhausted and have tried everything:

<Assembly: ContractNamespace("", ClrNamespace:="sb.api.notification")>

Here is a link to the code:
Question by:o1mattweber
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Ok. I'm not sure if this is the answer, because I'm still a noob with WCF, but I made some changes and I got the wsdl page to show (which I assume means it works). If this is not correct, please let me know. I also created a test project I made which uses the service. I received the hard-coded message when I tested.

    Please don't ask to explain what the issue was, because I honestly don't know. I just "trial-and-error" 'ed it :)

    Author Comment

    The error actually occurs when you try to POST to the service, not when you build. I am using Fiddler to do that.  It was a POX service.  I am not sure if your changes work because the way you reconfigured it appear to have made it a SOAP service.  I need it to be a plain xml service on HTTP-POST.  I am not sure how to edit he web.config file to do that.  The only way I know how is the way it was... I am a noob as well.

    I really appreciate you taking the time to look into it though.  Unfortunately, it has not yet lead to a resolution of the problem.  
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Can you try changing the binding in the web.config to:

    <endpoint address="" binding="webHttpBinding" contract="sb.api.notification.NotificationService">

    If that binding doesn't work, there is a list of other binding types here:

    Perhaps one of those will work.
    LVL 74

    Assisted Solution

    by:käµfm³d 👽
    Here is a tutorial on endpoints that may be of interest to you.

    Author Comment

    I will look into the endpoint.  However, I do not want to get side tracked.  The solution was working as POX just fine.   The issue was having the classes in a different assembly and they could not be serialized.  Let me mess around with and I'll post the results.

    I think this has something to do with the REST Starter Kit and it may be a bug.  This is an odd issue I just found.  If I add a class to the root of my project it works fine.  However, if I add it to a sub folder the project cannot detect that class and namespace.   Also, everything seems to be getting cached.  When I build the project  nothing changes in the browser.  I found there is a file called "sb.gpState" and when I delete it everything seems to work better for a while until that file comes back.

    I may just create a new solution and try again.  I will get back to you. Thanks again.  

    Accepted Solution

    I found the solution to the problem.

    1.)  The main issue was that the datacontact needs to have a namespace attribute (even if you are not using it).  This is only true when your datacontract in a different assembly.

    e.g.  <DataContract(Namespace:="")> _

    2.)  The other little bugs I found had to do with the REST Starter Kit.  I created a new solution and did it all from scratch and I did not have any of the odd caching issues.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
    This video is a brief demonstration on how to use security groups and Network Access Control Lists (ACLs) in Amazon Web Services.  Security groups and Network ACLs are mechanisms you can use in AWS to control network traffic.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now