简体   繁体   中英

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM