CodeSnip: Virtual Web Services Through Pattern Matching
page 4 of 4
by Rajesh Toleti
Feedback
Average Rating: 
Views (Total / Last 10 Days): 22707/ 38

Step 3: Write Code for Consuming the Web Service

I created a C# file to view the extracted information.

Listing 1:TaryaServiceCS File

<%@ Page Language="C#" Debug="true" %>

 

<script runat="Server">

void Page_Load()

{

TaryaService objTaryaService;

GetTaryaServicesMatches objMatches;

 

try

{

objTaryaService = new TaryaService();

objTaryaService.Timeout = 2000;

objMatches = objTaryaService.GetTaryaServices();

lblTitles.Text = objMatches.myServices[0];

}

catch (Exception e)

{

lblTitles.Text = e.Message;

}

 

}

</script>

 

<html>

<head>

<title>TestTaryaService.aspx</title>

</head>

<body>

<h3>

My Own Services</h3>

<font color="blue">

<asp:Label ID="lblTitles" runat="Server" />

</font>

</body>

</html>

 

We have a label in this file that shows the extracted information. On the Page Load event, we created TaryaService and the GetTaryaServicesMatches objects. objMatches is instantiated by calling GetTaryaServices on objTaryaService. Then we call the property myServices[0] on objMatches. Please note that we passed 0 as the argument to myServices. Here we are assuming we will get only one set of information.

In the following example, I replaced ul element with il:

&lt;li&gt;(.*?)li&gt;

 

In this case, we might get six elements; then we might have iterated from 0 to 5. We wrapped our code in a try-catch block in case we encounter any issues. When you execute everything properly, you should be able to see this, which wraps up this code snippet. Thanks for reading!


View Entire Article

User Comments

Title: great   
Name: Saif
Date: 2006-04-10 11:01:51 AM
Comment:
Thank you
Title: Good article   
Name: Chandan
Date: 2005-12-13 4:27:01 AM
Comment:
The article is good, and it gives a very good description about the virtual web service
Title: Great article   
Name: Kay Lee
Date: 2005-11-29 10:01:14 PM
Comment:
This is a great artice, and I like that you wrote it up. I just wanted point out that this capability may or may not become legally irritating. If the site you're leeching is considered a service for sale type of site, it can become a serious problem.

For the readers, please be discrete and courteous in regards to creating Virtual Web Services.
Title: Virtual Web Services Cannot Be Blocked   
Name: Deavon
Date: 2005-11-29 8:19:07 AM
Comment:
Steve Burch:

Unfortunately, there is no way to block a virtual web service; unless you block the content from the end user completely. Anything that can be represented by XML, HTML, RSS, or any other form of non-encrypted data storage can be reparsed and reused.

It is a similar concept to copy and pasting; and then reformatting with customized style sheets; except that, in the form of a VWS, that kind of functionality occurs automatically through compiled processing and parsing of the source file; to generate a SOAP file as the result.

Same data; different way of showing it.

Utilizing .NET's WSDL and Web Service architecture; it is easy to expose the data as a WSDL function; which is exactly what is occuring here.
Title: Virtual web service -- blocking?   
Name: steve burch
Date: 2005-11-27 5:35:01 PM
Comment:
you should show, if possible, how a web site can block someone from doing this.
Title: scan and read scriptedinfo   
Name: case
Date: 2005-11-25 1:54:18 AM
Comment:
How do you read a letter that's in scriped.
Title: Good Article   
Name: Pavan K
Date: 2005-11-23 5:44:54 AM
Comment:
Its a great article, as it gives complete insight into virtual web service. Its a highly recommended reading.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-26 10:46:34 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search