A.3. Accessing External Web ServiceUsing the Access MSN Search Web Service button, users can perform a search by making a call to the MSN Search Web Service. To use the MSN Search Web Service, you need to:
The search result returned by the MSN Search Web Service will display in a message box. Code the Access MSN Search Web Service button as follows: '=================================================== ' Access MSN Search Web Service '=================================================== Private Sub btnMSNWebService_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnMSNWebService.Click '---Create a request and response object--- Dim req As New SearchRequest Dim resp As SearchResponse '---Set the request type--- Dim arraySize As Integer = 1 Dim sr(arraySize) As SourceRequest sr(0) = New SourceRequest sr(0).Source = SourceType.Web sr(0).ResultFields = ResultFieldMask.All req.AppID = "B017E1DC4FBB461E67DA0E013AF46CBB4F7BEEA3" req.Query = "ClickOnce" req.CultureInfo = "en-US" req.SafeSearch = com.msn.search.soap.SafeSearchOptions.Strict req.Requests = sr Dim w As New MSNSearchService Try '---Invoke MSN Search Web service--- resp = w.Search(req) Dim resultStr As String '---Save the result into HTML--- resultStr = String.Empty For i As Integer = 0 To _ resp.Responses(0).Results.Length - 1 resultStr += resp.Responses(0). _ Results(i).Title & vbCrLf resultStr += resp.Responses(0). _ Results(i).Description &vbCrLf resultStr += resp.Responses(0). _ Results(i).DisplayUrl &vbCrLf resultStr += vbCrLf Next MsgBox(resultStr) Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Note: For simplicity, I will hard code the search query as "ClickOnce." |