cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Synthetic SOAP

ulf_thorn222
Inactive

Hi

Is there anyone who has done any synthetic SOAP by using Autocheck's?

If you have and succeeded - was there any tricks and what was the setup?

9 REPLIES 9

carol_ott
Inactive

You can monitor
SOAP by using an Autocheck web service. Please refer to Web Service in the Community; you can also monitor the response from the web service.

benjamin_wright
Dynatrace Pro
Dynatrace Pro

Cross-posting from an older forum entry:

Hi,

in case you need to monitor a web service and the Autochecks are not an option (either due to technical or license restrictions), you can use the below code to do so from an Agent Recorder script.

The function at the bottom will send a request to a webservice and return the response. You may want to put it inside a shared module.

You can call it like this for example:

Dim strURL As String
Dim strRequest As String
Dim strResponse As String

strURL = “http://web.service.url/...”

strRequest = “<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" xmlns:aa=""http://SAS.CAP.AA/webservices/AA"">" & _
"<soap:Header>" & _
“<… and all the rest of the XML request >” &_
"</soap:Envelope>"

strResponse = WebService.WebRequest(strURL, strRequest, "SOAPAction", "http://SAS.CAP.AA/webservices/AA/AuthenticateUserGetAllPermissions")
Option Explicit

Const SXH_SERVER_CERT_IGNORE_UNKNOWN_CA = 256
Const SXH_SERVER_CERT_IGNORE_WRONG_USAGE = 512
Const SXH_SERVER_CERT_IGNORE_CERT_CN_INVALID = 4096
Const SXH_SERVER_CERT_IGNORE_CERT_DATE_INVALID = 8192
Const SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS = 13056

'Sends a web request to a URL and returns the result
' If an additional header is needed, strAdditionalRequestHeaderName and strAdditionaRequestHeaderValue can be used
' bBasicCheck determines if some basic result checking should be done (response size and HTTP errors)
' bIgnoreSSLErrors allows supression of SSL errors

Function WebRequest(strURL As String, strRequest As String, Optional strAdditionalRequestHeaderName As String = "", Optional strAdditionalRequestHeaderValue As String = "", Optional strNTLMCredentialsUser As String = "", Optional strNTLMCredentialsPassword As String = "", Optional bBasicCheck As Boolean = True, Optional bIgnoreSSLErrors As Boolean = False) As String

Dim objXML As Object
Set objXML = CreateObject("MSXML2.ServerXMLHTTP")

Dim strResponse As String

' Prepare the request
If Length(strNTLMCredentialsUser) > 0 Then
' use authentication credentials
objXML.Open "post", strURL, False, strNTLMCredentialsUser, strNTLMCredentialsPassword
Else
' no authentication credentials passed
objXML.Open "post", strURL, False
End If

objXML.SetRequestHeader "Host", "localhost"
objXML.SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
objXML.SetRequestHeader "Accept-encoding", "zip"

If (Length(strAdditionalRequestHeaderName) > 0) Then
objXML.SetRequestHeader strAdditionalRequestHeaderName, strAdditionalRequestHeaderValue
End If

If (bIgnoreSSLErrors) Then
objXML.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
End If

' Execute the web request
objXML.sEnd strRequest

' Get the response
strResponse = objXML.ResponseText

If (bBasicCheck) Then


If Len(strResponse) <= 0 Then
WriteLog 2, "Web request returned response of length 0."
RaiseError "Web request returned response of length 0."
End If

Dim nHTTPError As Long
nHTTPError = InStr(1, strResponse, "HTTP Error", vbTextCompare)

If nHTTPError > 0 Then
Dim nTextEnd As Long
nTextEnd = InStr(nHTTPError, strResponse, "<", vbTextCompare)
If (nTextEnd > 0) And (nTextEnd > nHTTPError) Then
WriteLog 2, "Web request returned: " & strResponse
RaiseError "Web Request returned: " & Mid(strResponse, nHTTPError, nTextEnd - nHTTPError)
Else
WriteLog 2, "Web request returned: " & strResponse
RaiseError "Web Request returned: " & Mid(strResponse, nHTTPError, Len(strResponse) - nHTTPError)
End If
End If
End If

WebRequest = strResponse

Set objXML = Nothing
End Function

You’ll then have to parse strResponse for the result.

himanshumor
Inactive

please provide the complete code. where have you defined the variables WebService , SOAPAction ?

Hi,

Luke is right.

"SOAPAction" is just a String you pass. I had placed the second part of the code in a module named "WebService", hence the call to the function is "WebService.WebRequest".

luke_boyling
Dynatrace Pro
Dynatrace Pro

Hi Himanshu,

I'm guessing that the original forum poster had the bottom section of code placed in a shared module called WebService, from which you could call from any script using WebService.WebRequest (as in the top example shows). It also appears that "SOAPAction" simply refers to the HTTP header that needs to be added to an XML request to make it a SOAP request - it's a string, not a variable.

If putting the module code in a shared module called WebService doesn't work, maybe you could supply more information about any error messages you may be seeing.

Regards,

The original post is

https://answers.dynatrace.com/questions/124193/querying-a-web-service-in-an-agent-recorder-script.html.

himanshumor
Inactive

Hi Luke ! Thanks for the update

Looks like there is an issue with rights as i am not able to see this original post.

please see if you can paste the code here in this page.

The original post was in a different section of this forum. The code is exactly the same as the one posted in this thread, but less nicely formatted.

There is no difference between the code in the original post and the one posted above.