0
votes

I have created WCF service. It is working fine but our client want response in some specific form. I have shared 2 responses

enter image description here

My Code :

 [ServiceContract]
public interface IService
{
    [OperationContract]    
    MyClass GetMyData();

// TODO: Add your service operations here
}

// Use a data contract as illustrated in the sample below to add composite types to service operations. [DataContract] public class MyClass { int _id ; string _name ;

    [DataMember]
    public int ID
    {
        get { return _id; }
        set { _id = value; }
    }

    [DataMember]
    public string Name
    {
        get { return _name; }
        set { _name = value; }
    }
}
1
why would you do that? WCF is supposed to send SOAP messages. - Amit Kumar Ghosh
Because our client want response in that format - Pratik D Patil
What format do they want the response in? Your question is devoid of details. - Dai
Note that WCF 3.5 supports SOAP Envelopes and "plain" XML and JSON responses - in addition to supporting REST (via a hacked-on add-on). If you're using "web"-mode then WCF will automatically render responses as XML or JSON depending on the HTTP Accept header as-received from the client. - Dai
WCF was designed to support arbitrary protocols (indeed, TCP support is out-of-the-box) however this process is difficult and WCF is now generally considered an end-of-life platform. Its replacement: ASP.NET Web API, is strictly HTTP+REST-only and does not lend itself well to supporting SOAP or other protocols well at all. - Dai

1 Answers

1
votes

Your "Client Expectation" is a XSD file. They are meant to validate SOAP responses, not to be one. There are plenty of services which can validate your XML response based on your XSD.

If you client wants a XSD response, maybe you'll have to look for a tool to do that. I think this might help.