One of our engineers wrote an example of how to use the SOAP API (available in BES 7.0+) with Microsoft Visual Studios. The example is a simple application that allows you to type in a session query, submit them, get the results back, and display them.
Since many people using the SOAP API appear to like to use Visual Studios, we wanted to give you guys an example with this development platform. Additionally, we have the javascript widget example too.
The SOAP API works with version 7.0.7 (current) and above. You are likely on version 7.0.1 to encounter the above error while VS.NET 2005 is trying to create the Web Reference.
I am trying to use the VS example on BES 8.0, but when I update the web reference URL and point it to my web reports server (http://:52312/webreports?wsdl), I receive the following error when I build the application:
Error 11 The type or namespace name ‘RelevanceService’ does not exist in the namespace ‘BigFixSoap.razorbill_bes_webreports’ (are you missing an assembly reference?) C:\Documents and Settings\xxxxx\My Documents\Visual Studio 2005\Projects\BigFixSoap\BigFixSoap\Form1.cs 22 38 BigFixSoap
Hmm… I think something did change in the latest version, but I can’t remember what exactly. At any rate, this is something that you should be able to do without the sample project. Here’s some VB code with detailed comments:
Sub Main()
'Web Reports Username Dim user As String =
"abc123"
'Web Reports Password Dim pass As String =
"mypassword"
'The relevance clause that will be executed against web reports. For testing relevance against web reports, use http://<web reports>:52312/webreports?page=QNA Dim relevance As String =
"((name of it, ip address of it, (last report time of it) as universal string) of bes computers whose (name of it starts with "
"A"
")"
'This is the String array that will hold the results from the relevance query. Dim results() As String
'To add the Web Reference to a blank Visual Studio 2008 project, go to Project -> Add Service Reference -> Click "Advanced" -> Click "Add Web Reference" -> Enter the Web Reports WSDL URL (ex: http://<web reports>:52312/webreports?wsdl) Dim relevanceService As bes_webreports.RelevanceService = New bes_webreports.RelevanceService
'execute the relevance query, get the result results = relevanceService.GetRelevanceResult(relevance, user, pass)
'Write each result entry to the console so that the user can see the result. For Each result As String In results Console.WriteLine(result) Next Console.WriteLine(
"Press Enter to exit.") Console.ReadLine()
'What happens if it fails (because of incorrect relevance or invalid credentials)?
'A SOAPHeaderException is thrown. The message in the exception will indicate why it failed. End Sub