New SOAP API example using Visual Studios

(imported topic written by BenKus)

Hi everybody,

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.

http://support.bigfix.com/bes/misc/soapapi.html

Ben

(imported comment written by cwbynum91)

I get an error in VS 2005 when I try to create a web reference:

“The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF”

any ideas?

(imported comment written by Lee Wei)

Hi Wayne,

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.

Lee Wei

(imported comment written by SystemAdmin)

Does anyone have a SOAP example using Python?

(imported comment written by jerry91)

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

Any suggestions?

Thanks!

(imported comment written by Lee Wei)

Jerry,

Please send me the example that you are using so that I can take a look at it.

The SOAP API changed a little from 7.x to 8.x.

Although all the 7.x calls are still valid.

Lee Wei

(imported comment written by MattBoyd)

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

Also, here’s a post I made a few months ago that contains an example in VBScript: http://forum.bigfix.com/viewtopic.php?pid=25870#p25870

(imported comment written by jerry91)

Thanks Lee for helping me out with this.

For everyone’s reference, RelevanceService seems to be replaced with RelevanceBinding in version 8