477
Views
0
Helpful
0
Comments

Options
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 01-24-2014 12:28 PM
This document was generated from CDN thread
Created by: CHRISTIAN END on 16-09-2009 10:03:34 AM
Hello,
has someone done AXL Requests with VB.NET. I thought that it was not so difficult... But it is "for me"...
I have a Perl script running, doing some things for me. But i want a little graphical interface.
Thanks for the help...
Christian
Subject: RE: VB.NET Example for AXL Requests
Replied by: Dale Eichbauer on 08-10-2009 07:23:39 PM
Here's a VB.Net function I've created that seems to work reasonably well. I've only run this on V 7. I have a totally different one for V 4.3. I'm looking for analog devices in case you are wondering about some of the select parameters. I pass the IP address, ID, and password. I've pulled out some proprietary info, but I think it should still work as is. Hope this helps.
Public Function Poll_CM(ByVal sServer As String, ByVal sID As String, ByVal sPwd As String) As Integer
Dim sPost As String
Dim crlf As String
Dim iReturnCode As CURLcode
Dim sOptions As Slist
Dim easy As Easy
Dim wf As Easy.WriteFunction
Dim sf As Easy.SSLContextFunction
Dim df As Easy.DebugFunction
Dim sbReturned As System.Text.StringBuilder
crlf = Chr(13) & Chr(10)
sbReturned = New System.Text.StringBuilder
sReturned = ""
sConsolidated = ""
bCM7Flag = True
sPost = "<?xml version=""1.0"" encoding=""UTF-8""?>" & crlf
sPost = String.Concat(sPost, "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"">" & crlf)
sPost = String.Concat(sPost, "<SOAP-ENV:Body>" & crlf)
sPost = String.Concat(sPost, "<axlapi:executeSQLQuery xmlns:axlapi=""http://www.cisco.com/AXL/API/1.0"" ")
sPost = String.Concat(sPost, "xmlns:axl=""http://www.cisco.com/AXL/API/1.0"" ")
sPost = String.Concat(sPost, "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" ")
sPost = String.Concat(sPost, "sequence=""1"" ")
sPost = String.Concat(sPost, "xsi:schemaLocation=""http://www.cisco.com/AXL/API/1.0 axlsoap.xsd"">" & crlf)
sPost = String.Concat(sPost, "<sql>SELECT NumPlan.DNOrPattern, NumPlan.AlertingName, Device.Name,Device.Description, (SELECT location.name FROM location WHERE Location.pkid = Device.fkLocation) as LocationName, TypeModel.Name as ModelName, Device.fkEnduser as OwnerKey FROM DeviceNumPlanMap, NumPlan, Device, TypeModel WHERE DeviceNumPlanMap.fkNumPlan=NumPlan.pkid AND DeviceNumPlanMap.fkDevice=Device.pkid AND Device.tkModel = TypeModel.Enum AND (Device.tkModel ='10' OR Device.tkModel = '12' OR Device.tkModel = '30027') ORDER BY Device.Name</sql>" & crlf)
sPost = String.Concat(sPost, sPost & "</axlapi:executeSQLQuery>" & crlf)
sPost = String.Concat(sPost, "</SOAP-ENV:Body>" & crlf)
sPost = String.Concat(sPost, "</SOAP-ENV:Envelope>" & crlf)
Try
Curl.GlobalInit(CURLinitFlag.CURL_GLOBAL_ALL)
Easy = New Easy
' Set up write delegate
wf = New Easy.WriteFunction(AddressOf OnWriteData)
' and the SSL delegate
sf = New Easy.SSLContextFunction(AddressOf OnSSLContext)
' and the rest of the cURL options
easy.SetOpt(CURLoption.CURLOPT_URL, "https://" & sServer & ":8443/axl/")
easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf)
easy.SetOpt(CURLoption.CURLOPT_CAINFO, Environment.SystemDirectory & "\ca-bundle.crt")
easy.SetOpt(CURLoption.CURLOPT_USERPWD, sID & ":" & sPwd)
easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, False) ' don't check the server's certificate
easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYHOST, 1) ' check for existence of certificate but not hostname match
easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS, sPost)
sOptions = New Slist
sOptions.Append("Content-type: text/xml;") ' one element list so far. repeat append to add any others
easy.SetOpt(CURLoption.CURLOPT_HTTPHEADER, sOptions)
df = New Easy.DebugFunction(AddressOf OnDebug)
' easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df) ' turn this and next one on for debugging
' easy.SetOpt(CURLoption.CURLOPT_VERBOSE, True)
iReturnCode = easy.Perform()
easy.Cleanup()
Curl.GlobalCleanup()
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
iValidStart = InStr(sReturned, "<return>")
iValidEnd = InStr(sReturned, "</axl:executeSQLQueryResponse>")
If (iValidStart > 0) And (iValidEnd > 0) Then
sReturned = Mid(sReturned, iValidStart, iValidEnd - iValidStart)
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
sbReturned = Nothing
Return 0
Else
sReturned = " "
MsgBox("Invalid Data returned from server")
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
sbReturned = Nothing
Return 999
End If
Catch ex As Exception
MsgBox(ex.ToString())
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
sbReturned = Nothing
Return 999
End Try
End Function
Subject: RE: VB.NET Example for AXL Requests
Replied by: CHRISTIAN END on 21-10-2009 09:43:58 PM
Hello Dale,
thank you for the reply. I tried the function for me. But i didn't get it running...
What did you use for the IMPORTS in vb.net?
And there are some undeclared vars in the function...
It is possible that i use it wrong... I created a new Form in Visual Studio and have pasted the code into the form.
Or have functions to be used in other ways in vb.net?
Sorry for this simple questions, but my knowledge in vb.net is not so much...
Thanks a lot...
Christian
Subject: RE: VB.NET Example for AXL Requests
Replied by: Wai Ming Yap on 27-11-2009 02:09:03 AM
Hi Dale,
I'm new to this as well. I tried your program but it iValidStart=0 and iValidEnd=0.
Seems as though it has returned nothing.
Would it be possible for you to send me a copy of your program and I have a look at it to see what I have missed out?
Thanks.
Wai Ming
Created by: CHRISTIAN END on 16-09-2009 10:03:34 AM
Hello,
has someone done AXL Requests with VB.NET. I thought that it was not so difficult... But it is "for me"...
I have a Perl script running, doing some things for me. But i want a little graphical interface.
Thanks for the help...
Christian
Subject: RE: VB.NET Example for AXL Requests
Replied by: Dale Eichbauer on 08-10-2009 07:23:39 PM
Here's a VB.Net function I've created that seems to work reasonably well. I've only run this on V 7. I have a totally different one for V 4.3. I'm looking for analog devices in case you are wondering about some of the select parameters. I pass the IP address, ID, and password. I've pulled out some proprietary info, but I think it should still work as is. Hope this helps.
Public Function Poll_CM(ByVal sServer As String, ByVal sID As String, ByVal sPwd As String) As Integer
Dim sPost As String
Dim crlf As String
Dim iReturnCode As CURLcode
Dim sOptions As Slist
Dim easy As Easy
Dim wf As Easy.WriteFunction
Dim sf As Easy.SSLContextFunction
Dim df As Easy.DebugFunction
Dim sbReturned As System.Text.StringBuilder
crlf = Chr(13) & Chr(10)
sbReturned = New System.Text.StringBuilder
sReturned = ""
sConsolidated = ""
bCM7Flag = True
sPost = "<?xml version=""1.0"" encoding=""UTF-8""?>" & crlf
sPost = String.Concat(sPost, "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"">" & crlf)
sPost = String.Concat(sPost, "<SOAP-ENV:Body>" & crlf)
sPost = String.Concat(sPost, "<axlapi:executeSQLQuery xmlns:axlapi=""http://www.cisco.com/AXL/API/1.0"" ")
sPost = String.Concat(sPost, "xmlns:axl=""http://www.cisco.com/AXL/API/1.0"" ")
sPost = String.Concat(sPost, "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" ")
sPost = String.Concat(sPost, "sequence=""1"" ")
sPost = String.Concat(sPost, "xsi:schemaLocation=""http://www.cisco.com/AXL/API/1.0 axlsoap.xsd"">" & crlf)
sPost = String.Concat(sPost, "<sql>SELECT NumPlan.DNOrPattern, NumPlan.AlertingName, Device.Name,Device.Description, (SELECT location.name FROM location WHERE Location.pkid = Device.fkLocation) as LocationName, TypeModel.Name as ModelName, Device.fkEnduser as OwnerKey FROM DeviceNumPlanMap, NumPlan, Device, TypeModel WHERE DeviceNumPlanMap.fkNumPlan=NumPlan.pkid AND DeviceNumPlanMap.fkDevice=Device.pkid AND Device.tkModel = TypeModel.Enum AND (Device.tkModel ='10' OR Device.tkModel = '12' OR Device.tkModel = '30027') ORDER BY Device.Name</sql>" & crlf)
sPost = String.Concat(sPost, sPost & "</axlapi:executeSQLQuery>" & crlf)
sPost = String.Concat(sPost, "</SOAP-ENV:Body>" & crlf)
sPost = String.Concat(sPost, "</SOAP-ENV:Envelope>" & crlf)
Try
Curl.GlobalInit(CURLinitFlag.CURL_GLOBAL_ALL)
Easy = New Easy
' Set up write delegate
wf = New Easy.WriteFunction(AddressOf OnWriteData)
' and the SSL delegate
sf = New Easy.SSLContextFunction(AddressOf OnSSLContext)
' and the rest of the cURL options
easy.SetOpt(CURLoption.CURLOPT_URL, "https://" & sServer & ":8443/axl/")
easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf)
easy.SetOpt(CURLoption.CURLOPT_CAINFO, Environment.SystemDirectory & "\ca-bundle.crt")
easy.SetOpt(CURLoption.CURLOPT_USERPWD, sID & ":" & sPwd)
easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, False) ' don't check the server's certificate
easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYHOST, 1) ' check for existence of certificate but not hostname match
easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS, sPost)
sOptions = New Slist
sOptions.Append("Content-type: text/xml;") ' one element list so far. repeat append to add any others
easy.SetOpt(CURLoption.CURLOPT_HTTPHEADER, sOptions)
df = New Easy.DebugFunction(AddressOf OnDebug)
' easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df) ' turn this and next one on for debugging
' easy.SetOpt(CURLoption.CURLOPT_VERBOSE, True)
iReturnCode = easy.Perform()
easy.Cleanup()
Curl.GlobalCleanup()
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
iValidStart = InStr(sReturned, "<return>")
iValidEnd = InStr(sReturned, "</axl:executeSQLQueryResponse>")
If (iValidStart > 0) And (iValidEnd > 0) Then
sReturned = Mid(sReturned, iValidStart, iValidEnd - iValidStart)
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
sbReturned = Nothing
Return 0
Else
sReturned = " "
MsgBox("Invalid Data returned from server")
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
sbReturned = Nothing
Return 999
End If
Catch ex As Exception
MsgBox(ex.ToString())
easy = Nothing
wf = Nothing
sf = Nothing
sOptions = Nothing
df = Nothing
sbReturned = Nothing
Return 999
End Try
End Function
Subject: RE: VB.NET Example for AXL Requests
Replied by: CHRISTIAN END on 21-10-2009 09:43:58 PM
Hello Dale,
thank you for the reply. I tried the function for me. But i didn't get it running...
What did you use for the IMPORTS in vb.net?
And there are some undeclared vars in the function...
It is possible that i use it wrong... I created a new Form in Visual Studio and have pasted the code into the form.
Or have functions to be used in other ways in vb.net?
Sorry for this simple questions, but my knowledge in vb.net is not so much...
Thanks a lot...
Christian
Subject: RE: VB.NET Example for AXL Requests
Replied by: Wai Ming Yap on 27-11-2009 02:09:03 AM
Hi Dale,
I'm new to this as well. I tried your program but it iValidStart=0 and iValidEnd=0.
Seems as though it has returned nothing.
Would it be possible for you to send me a copy of your program and I have a look at it to see what I have missed out?
Thanks.
Wai Ming
Labels: