Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft C# Professional Projects - Premier Press.pdf
Скачиваний:
177
Добавлен:
24.05.2014
Размер:
14.65 Mб
Скачать

662 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE

val= val+1;

if(val>0 & val<=9)

{

str = “O000” + Convert.ToString(val);

}

else if(val>9 & val<=99)

{

str =”O00” + Convert.ToString (val);

}

else if(val>99 & val <=999)

{

str = “O0” + Convert.ToString (val);

}

else

{

str = “O” + Convert.ToString (val);

}

return str;

}

}

}

After creating the Web service, you can test the Web service.

Testing the Web Service

To test the Web service, press the F5 key or select the Start option on the Debug menu. Because you have tested most of the Web methods while creating them, you can test the remainder of the Web methods.

Testing the SrchAuthor() Web Method

On testing the SrchAuthor() Web method, the method returns records for the specified author. Figure 29-9 shows the records returned by the SrchAuthor() Web method.

DEVELOPING WEB SERVICES

Chapter 29

 

663

 

 

 

 

 

 

FIGURE 29-9 The records returned by the SrchAuthor() Web method

Testing the SrchCategory() Web Method

Figure 29-10 shows the records based on the category specified by the user in the

SrchCategory() Web method.

FIGURE 29-10 The records returned by the SrchCategory() Web method

664 Project 5 CREATING A WEB PORTAL FOR A BOOKSTORE

Testing the SrchTitle() Web Method

When the user wants to search for a particular book, the user can specify the title of the book as the search criteria. Figure 29-11 shows the record returned by the

SrchTitle() Web method.

FIGURE 29-11 The record returned by the SrchTitle() Web method

Once you have created a Web service, you need to secure your Web service. The following section discusses how to secure a Web service.

Securing a Web Service

It is essential that you secure the Web service that you create.This would prevent anyone else from tampering with your Web service. To secure a Web service, there are several attributes associated with the Web service, as shown:

Authentication

Authorization

Auditing