Archive for the ‘’ Category

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: , ,

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.