Tuesday, January 31, 2012

How to Create Web Service based From .XSD File

Many client just provide you .xsd file and you need to create web service for them so they can utilize your web service to post the data.

Below are the few steps for the same ,so you can easily create web service from .xsd file.


1) Put your .XSD file on hard Disk (either C /D/E).

2) Then Open command prompt of Visual Studio 2010. (Refer Below Image)



3 ) Now type below command in this

xsd.exe -c -l:c# E:\WebServiceProject\YourXSDFile.xsd

4) This will generate Proxy Class for you and It also give the location information of this class (it ends with .CS)







5) Then create Web Site with app Folder and then put this .CS (ProxyFile) file in this

And also create one Service.Cs

7 Make sure both have same name space .

8) Now create public class in service.cs and create web method under this

Example

[WebMethod]

public bool message([System.Xml.Serialization.XmlElementAttribute("staffed-call-intake-form-query")] staffedcallintakeformquery LeadmessagePayloadConsumerintakeformIntakeform)

9 ) Now implement your business logic in service.cs

10) Create Service.asmx and put the below code.

<%@ WebService Language="C#" CodeBehind="SFDCProxy.asmx.cs" Class="Classified.ClassifiedProxy" %>


and your web service is ready.

If you need detail code then email me to viralpala@gmail.com .

Your feedback always appreciated