Web Service is one of the most important development technologies in the current Internet world, we can use XML (Scalable Markup Language), SOAP (Simple Object Access Protocol), WSDL (Web Services Description Language) and UDDI (unified description, discovery and The integrated protocol) uses the Web Service technology for business applications and client connections in standard way. XML can be used to construct data, and SOAP can be used for data transfer, and WSDL can be used to describe services and UDDI can be used to obtain a list of available services. Web Service allows applications to communicate with each other without considering hardware systems, operating systems, and programming languages. The Web Service is different from the previous model that it does not provide a user interface, and the Web Service discloses the programmable business logic. Therefore, users can add their interface to the application as needed. In this article, we will learn how to use Microsoft Visual Basic.Net to implement Google Web Service.
Google Web Service
Google is a very important Web site that provides a web service to the public, allowing applications to use features such as search and spell checks. Now let's take a look at how to use this service in the app over Visual Basic.net. Before accessing the Google Web Service, we need to create a Google account and get a license key. Only in this way, we can do about 1,000 automatic queries in one day. Visit http://www.google.co.nz/apis/ when creating a Google account. Once the email address and password are entered, Google will send your license key to your mailbox via email. We will use the license key in the examples herein. From here, we have already obtained the required license key, follow we will create an application in Visual Basic.NET to create custom search by using Google's Web Service API (App Programming Interface). And spell inspector. Open Visual Studio .NET and create a new Windows application engineering. Name this project as GoogleAPi and click OK:
Add a web reference to Google Web Service, we need to add a web reference pointing to Google Web Service (this is very similar to adding the reference to the COM / ActiveX object, but after adding the web reference, we have the right to access the Google server. XML Web Service). Open your solution explorer, right-click References and click Add Web Reference, or you can select the Project Menu and then click Add Web Reference. In the address bar, type http://api.google.com/googlesearch.wsdl (Note: Please make sure that the content you typed is correct, that is, the same, especially note that the URL is case sensitive. of):
After entering the URL address and press Enter keys, Google Web Service will import, and the screen you see should be similar to the window displayed in the above example. Finally, click the Add Reference button to add this web reference to our project. Execute Google Web Service Please click on the Web reference in the Solution Browser window so you can check the Google web reference we have added before this. We rename it as Google, the specific method is to right-click this reference and click Rename:
Create a user interface as shown below. Add the following controls: a) Search for: txtSearch - text box lbl_TotalFound - label btn_Search - buttons b) for spell checking: Single-label btn_CheckSpelling button add the following code into the Google search button (btn_Search) of - txt_CheckSpelling - text box lbl_CorrectSpelling In the event:
Private sub btn_search_click (Byval Sender as system.Object, _
Byval e as system.eventargs) Handles BTN_Search.click
Dim MylicenseKey As String 'Variable To Store The License Key
'Declare Variable for the Google Search Service
DIM myservice as google.googlesearchService = new _
Google.gogleSearchService ()
'Declare Variable for the Google Search Result
DIM MyResult As Google.googlesearchResult
'Please your license key here
MylicenseKey = "TGCTJKYOS3YITLYZI9HG5QUBRY8BGQIM"
'Execute Google Search on The Text Enter and License Key
MyResult = myservice.dogooglesearch (MylicenseKey, _
TXTSEARCH.TEXT, 0, 1, FALSE, "" "" "" "" "" "" "
'Output The Total Results Found
LBL_TOTALFOUND.TEXT = "Total Found:" & _
Cstr (MyResult.estimatedTotaResultscount)
End Sub
Enter the following code to the spell check button (btn_checkspelling) Click the event:
Private sub btn_checkspelling_click (Byval Sender as system.object, _
Byval e as system.eventargs) Handles BTN_CHECKSPELLING.CLICK
Dim MylicenseKey As String 'Variable To Store The License Key
'Declare Variable for the Google Search Service
DIM myservice as google.googlesearchService = new _
Google.gogleSearchService ()
'Declare Variable for the Google Search Result
DIM MyResult As String
'Please your license key here
MylicenseKey = "TGCTJKYOS3YITLYZI9HG5QUBRY8BGQIM"
'Execute Google Search on The Text Enter and License KeymyResult = MyService.dospellingSuggestion (MylicenseKey, _
TXT_CHECKSPELLING.TEXT)
'Output the results
LBL_CORRECTSPELLING.TEXT = "DID you mean:" & myresult
End Sub
Now we have completed the application's encoding work, then you can run the application and type text in the search box, and then click the Google Search Buttons to view the number of results found. We can also test and verify Google spell checks.
Our Web Service implements the expected goals and can work normally. And our implementation is just a few lines of code!
in conclusion
This article describes how to integrate Web Service into the application. You can proceed as follows: • Publish a regular subscription search request to monitor the web about a new message about a host. · Make a market research, the method is to analyze the difference in the amount of information available information available. · Search through non-HTML interfaces, such as command lines, papers, or visualization applications. · Conduct innovation activities to fully use the information on the Web. • Add Google spell check to the application. The search syntax supported by Google Web Service is the same as the search syntax supported by the Google.com Web site. At the same time, it provides up to 1,000 queries per day for registration using Google Web Service (this number is enough for small / medium-sized applications)