September 23, 2005

Custom Objects with Web Services

Web Services are not .net specific. Most of them might think its something Microsoft invented. What Microsoft have done is they implemented a common standard. To create a web service in .net is really easy. But you should understand the concept behind it. You can find the public web services which available through Microsoft UDDI service.(http://uddi.microsoft.com/visualstudio/ )

So today im going to explain how to return a custom object through web service. I will explain the scenario from a simple diagram.( banks needs a valid telephone number to issue a credit card its a fact)




















In this scenario Telephone Company is offering a web service to its partners to get the customer just by supplying customers telephone number.

Customer class:

public class Customer
{
public Customer()
{
//
// TODO: Add constructor logic here
//
}

string _name;
string _age;
string _company;

public string Name
{
get{return _name;}
set{_name = value;}
}

public string Age
{
get{return _age;}
set{_age = value;}
}
public string Company
{
get{return _company;}
set{_company = value;}
}
}

GetCustomer web service method which returns the customer object

[WebMethod]
public Customer GetCustomer()
{
//can be perform any database functions

Customer customer = new Customer();
customer.Name = "Ludmal de silva";
customer.Age = "25";
customer.Company = "E-Solutions";

return customer;
}


Now we can use this web service by simply adding a web reference to our project.(you guys should know how to add a web reference its really simple).

Finally you can get the customer object which returns from the web service. Code below.

//Customer object
CustomerService.Customer customer = new CustomerService.Customer();

//CustomerService object
CustomerService.Service1 myCustomerService = new CustomerService.Service1();

///Get the customer from the WebService
customer = myCustomerService.GetCustomer();

//Assigning the values to the UI
this.Label1.Text = customer.Name;
this.Label2.Text = customer.Company ;
this.Label3.Text = customer.Age ;

What I was trying to do is to give a basic idea about web services & to use the custom object with web services. I highly appreciate comments. (my writing skills might be poor...) But all the questions /comments are welcome.

18 comments:

Mahasen said...

It’s a nice piece. Good reading for some one who wants a simple straight forward sample.

My idea is when writing technical artifacts, we should think of what we might want to read at different circumstances. If we are tight in a schedule and want to get some thing done we need some thing like your article, simple and straight forward no bluffs and sweet talks. If we are passionate about a certain technology and want to learn it inside out; then we need detailed clear and long articles. If we just need to get the work done but our work isn’t straight forward we need a FAQ kind of thing… so if we write so serve our need, it would serve some one else’s need as well :)

Anonymous said...

Custom software development is a thing that is increasingly growing popular. People nowadays don’t usually prefer the readymade packages for the fact that they might at times fall short of the requirements and specifications of the concern. The increasing demand of the custom software development has also compelled quite a many software company to provide this service. Countries like India have many companies that deal in such software services. http://www.infysolutions.com

ecommercewebmaster said...

If you are looking out for apt ecommerce solution to spruce up your online business,then the offshore software outsourcing company Infysolutions is the ideal destination foryou. The url http://www.infyecommercesolution.com/ provides the details on specific ecommerce solutions that you can avail of to expand and boost up your online business.

Anonymous said...

If I were gold für wow a boy again,world of warcraft gold I would practice perseverance wow gold cheap more often,maple meso and never give up a thing because it was or inconvenient. If we want light,Maple Story Account we must conquer darkness. Perseverance can sometimes equal genius in its results.wow gold kaufen “There are only two creatures,”cheap maplestory mesos syas a proverb, “who can surmount the pyramids—the eagle and the snail.” If I were a boy again,wow geld I would school myself into a habit of attention;maple mesos I would let nothing come between me and the subject in hand.maple story power leveling I would remember that a good skater never tries to skate in two directions at once.billig wow gold The habit of attention becomes part of our life, if we begain early enough. I often hear grown up people say maple story items“ I could not fix my attention on the sermon or book, although I wished to do so” , wow powerlevelingand the reason is, the habit was not formed in youth. If I were to live my life over again,wow leveling I would pay more attention to the cultivation of the memory. I would strengthen that faculty by every possible means,wow power leveling and on every possible occasion.maplestory powerleveling It takes a little hard work at first

website design New York City said...

thanks u r information

Anonymous said...

Cool stuff buddy... Awesome..

Manjuke Fernando said...

Very useful.. Short and sweet....

Anonymous said...

My name is Kelly Smith I was browsing internet and found your blog. The author did a great job. I will subscribe to your RSS feeds. Thank you for your contribution. I am a web designer myself. And here some examples of the websites that I designed for loans canada payday loans company.

Custom Software Developer India said...

Hello, it wants new ideas and techniques everytime. thank you for sharing this.

Custom Software Developer India

Web Design Company said...

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck! Web Design Company

Smartphone Development said...

i read this entire article. Really felt very happy to see this useful & informative info. Thanks for sharing with us.

Virtual Administrative Assistant said...

I just wanted to add a comment here to mention thanks for you very nice ideas. Blogs are troublesome to run and time consuming thus I appreciate when I see well written material. Your time isn’t going to waste with your posts. Thanks so much and stick with it No doubt you will definitely reach your goals! have a great day!

Melbourne embroidery said...

Interesting and important information. It is really beneficial for us. Thanks

Botox Chicago said...

I’ve learned a lot from your blog here, Keep on going, my friend, I will keep an eye on it,

Fort Lauderdale criminal lawyer said...

Interesting layout on your blog. I really enjoyed reading it and also I will be back to read more in the future.

Fulton Septic Cleaning said...

All that we are is the consequence of what we have estimation. Wait… Has anyone exhorted dissertation to you. Keep the articles progressing !

online auction said...

Interesting and important information. It is really beneficial for us. Thanks

Gainesville apartment said...

This is really an interesting blog as it focuses on the very important topic. i came to know about so many things or tips.