Simon
Simon

Reputation: 205

Create C# API Webservice from XSD file

I have been given an XSD file and a sample XML file of a post coming from an application a company uses. I need to capture the data posted, put it into an object and then do some stuff with it. Does anyone have any good walk throughs of how to do this ?

Upvotes: 0

Views: 929

Answers (1)

mp3ferret
mp3ferret

Reputation: 1193

Just off the top of my head so may be a few typos etc - but the general gist would be something like :

For WCF, create your service insterface (.cs file):

[ServiceContract]
public interface IMyService
{
    [OperationContract]
    bool MyServiceFucntion (string xml);
}

create your implimention of that service (svc file)

public class MyService : IMyService
{
    public bool MyServiceFunction(string xml)
    {
        SuppliedXSD x = new SuppliedXSD();
        x.LoadXml(xml);
        // do stuff with your data.
    }
}

You'll need to setup the servicve to run somewhere - if iis is hosting it then you'll need to add the bindings to the webconfig file - plenty of examples on line. Or you could host it as a standalone proc - again - lots of examples only a google search away.

Upvotes: 3

Related Questions