Create XSD from XML file

September 1, 2010 Leave a comment

I recently required to generate XSD file from XML file,

To accomplish this i used built in tool provided in Visual studio itself,

What you need to do is open your xml file, as you open xml file IDE will show up with new option tab available to generate xsd file option.

Also you can do this from command prompt, there is a xsd.exe file located at

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin or C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin,

set this path to command prompt then you can set any below option and it will generate xsd file,

xsd.exe <schema>.xsd /classes|dataset [/e:] [/l:] [/n:] [/o:] [/s] [/uri:]

xsd.exe <assembly>.dll|.exe [/outputdir:] [/type: […]]

xsd.exe <instance>.xml [/outputdir:]

xsd.exe <schema>.xdr [/outputdir:]

Reference: here

Categories:, xml Tags: , ,

Do you know this about RIA service:

August 31, 2010 3 comments

RIA services strictly follow Naming convention and signatures.Like Method that are meant to query and return data to the client should begin with one of the following prefixes:Get,Fetch,Query,Retrieve and Select.This methods should have return type as IEnumerable, IQueryable, or a single instance of the entity type.However, you can have any number of parameters in a query method, which can help you to filter the results. Below Table lists the various combinations of naming conventions that you can follow when you add your own CRUD operations, if you wish for them to be exposed by the WCF RIA Services framework.

Data method

Required Method Prefix

Required Method Signature

Query Data Get, Fetch, Query, Retrieve,

or Select

IEnumerable<T> GetData()

IQueryable<T> GetData()

Create Data Insert, Add, Create void InsertData(T entity)
Update Data Update, Change, Modify void UpdateData(T entity)
Delete Data Delete, Remove void DeleteData(T entity)

If, for some reason, you are unable to follow the WCF RIA Services naming conventions in your own custom methods, you also have the option of adding specific attributes above the method declarations.

The WCF RIA Services framework also looks for these attributes when determining which methods to make available to clients. You can use any of the following attributes above your custom methods: [Query], [Insert], [Update], and [Delete]. For example, if you have a method that searches for specific foods called FindExercises, by default, this method is not exposed to the client.

If you were to add the [Query] attribute directly above the method declaration then the framework would, in fact, expose it to clients.

Categories: RIA Tags:

Consume web service from client side/javascript

May 17, 2010 Leave a comment

In many scenarios of web application development we come across the point when we need to call some web service from client side or by javascript,

The ASP.NET 2.0 AJAX Extensions enable this exact same experience of seamless proxy generation for Web services for client-side JavaScript that will run in the browser.

You can author an .asmx file hosted on your server and make calls to methods on that service through a client-side JavaScript class. For example, Figure 1 shows a simple .asmx service that implements a faux stock quote retrieval (with random data).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<strong>[System.Web.Script.Services.ScriptService]  //This is the line used to enable web service from client side</strong>
public class Service : System.Web.Services.WebService
public Service () {
//Uncomment the following line if using designed components</div>
public string HelloWorld() {
return "Hello World";
After this you need to add below code to your aspx page,
<asp:ScriptManager ID=”_scriptManager” runat=”server”>
<asp:ServiceReference Path=”WebService.asmx” />
this will register your web service on client side,to call this web service you just need to write below code:
<div>&lt;script type="text/javascript"&gt;</div>
<div>function onclick1() {</div>
<div>function OnLookupComplete(result) {</div>
<div>var res = document.getElementById("_resultLabel");</div>
<div>res.innerHTML = "&lt;b&gt;" + result + "&lt;/b&gt;";</div>
<input onclick=”onclick1();” id=”_lookupButton” type=”button” value=”Lookup” />
Even you can handle your custom events after error or on completion of call to web service like i wrote  “OnLookupComplete” event.
Reference site:


New features of c# framework 4.0

May 3, 2010 1 comment
Below are the new features of framework 4.0:
1]Dynamic:Now you can create dynamic objects and let their types be determined at run time.
2]Covariance and Contravariance:Variance on generic type parameters in interfaces and delegates is another important feature of this release. It doesn’t add much new functionality, but rather makes things work as you expected them to in the first place. The major advantage is hidden in this simple line, which didn’t compile until C# 4.0
3]Optional (or Default) Parameters:Now you can assign a default value to a parameter right within the method declaration. The user of the method can either pass a value or simply skip the argument. In the latter case, the default value is passed to the method.
4]Named Arguments:The order of parameters in a method declaration and the order of arguments you pass when calling the method don’t need to match anymore. You can provide arguments in any order you like by specifying parameter names in a method call. This might also improve the readability of your code.
5]Improved COM Interop:The introduction of the dynamic keyword, optional parameters and named arguments enables improvement of COM interop.