techshaman
techshaman

Reputation: 148

Response objects from WCF Service

I have a WCF service that looks something like this

 [OperationContract]
 [WebGet(ResponseFormat = WebMessageFormat.Xml)]
 CompositeType GetCompositeTypeForUser(int userid);

...with a CompositeType object that looks something like this:

    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public List<string> stuffAroundMe = new List<string>();

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }

Whenever I call my service I get back a blob of XML data that describes the particular CompositeType. Is there a way to get a CompositeType object back on the client side without having to parse a bunch of XML and manually create a new CompositeType object?

Additionally I have code that lives both in C# on Visual Studio as well as Java on an Android app (the code that is actually calling the web service). Is there a way to avoid parsing lots of xml when I can control the objects being passed from both sides?

Upvotes: 1

Views: 1403

Answers (1)

Anders Abel
Anders Abel

Reputation: 69260

Use a web service client library instead of calling the service manually. For .NET the svcutil tool would be used to create the required client code. It looks like something similar is available for java: What tools exist in Java that are equivalent to svcutil.exe for .NET?

Upvotes: 1

Related Questions