Expose custom type through WCF service

Posted on 2007-10-20
Last Modified: 2008-01-09

I've got a WCF service and client.  I'd like the service to expose a custom structure used to return some data to the client of the form:

        Dim Fields() As String
    End Structure

AUTHORIZATION_RESPONSE is an enum and Fields is an array of strings.

The service does not define this structure however, it is defined that another library (IS.Services) which is included as a reference to the service.  I get this error when I create an interface and method on the service which take string parameters and return a parameter of type TRANSACTION_RESPONSE:

Type 'IS.Services+TRANSACTION_RESPONSE' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute."

The question is, how can I add the DataContractAttribute markers to a library that is used as a reference within the service. It would be easy if the service defined the structure itself - but it does not.

This is the WCF interface definition:

using IS.Services;
    public interface IServices
       'IS.Services.TRANSACTION_RESPONSE AddTransaction(string sMain);
Question by:ossentoo
    LVL 21

    Accepted Solution

    In my opinion all responses and request classes SHOULD be marked with the DataContract attribute and all its members should be marked with the Data member attribute for it to be sent over the wire. Transaction Response SHOULD be marked with the data contract attribute. If you dont have control over it, create your own class and copy the attributes from the original class to the newly create data contract class object.

    Author Comment

    Thanks for the answer! It worked.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    729 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

    20 Experts available now in Live!

    Get 1:1 Help Now