Test SAP Connections and Versions failing with an "Couldn't find a valid mid server"


During implementation of Software Asset Management while creating create a connection to SAP the connection fails.
When we create the connection and choose the related link "Test SAP Connections and Versions" we get an error "couldn't find a valid mid server".
See the attached screenshot.

Release or Environment



The error in the System Logs for this transaction will look like below:

Error Default-thread-9 72CCEA9FDBA064501DFA2D8913961927 txid=e8f1f69bdb24 SEVERE *** ERROR *** *** Script: SAPImportWorker Exception while executing the api GET_SAP_VERSION Error is Error: SAMSoapHandler: Couldn't find a valid mid server;
07:09:53.149 Error Default-thread-9 72CCEA9FDBA064501DFA2D8913961927 txid=e8f1f69bdb24 SEVERE *** ERROR *** *** Script: SAPImportWorker.getLatestSapVersion : Can not get the lastest SAP version, returned with response : {0}SAMSoapHandler: Couldn't find a valid mid server;
07:09:53.151 Info Default-thread-9 72CCEA9FDBA064501DFA2D8913961927 txid=e8f1f69bdb24 GlideSession message was modified by sanitization. [message=Request failed with response : SAMSoapHandler: Couldn't find a valid mid server][sanitized=Request failed with response : SAMSoapHandler: Couldn't find a valid mid server];

There could be multiple causes for seeing the error:
1] Verify the connection section has all the required attributes.

2] Verify if the SOAP Message attributes are set correctly:

3] Ensure the Mid server associated to the WSDL is up and running.
4] Verify if the credentials are set correctly.

5] From the System Logs error message "Can not get the lastest SAP version", the script responsible for the above error is found in the below link:

5.1]  In SAMSoapHandler.execute, we call SAMSoapHandler.getMIDServer which calls back-end java Mid selector code. However, from verifying the function definition that tests the mid server connection with the target in the code [selecAnyMidServer(null, target, null)] this seems to expect an IP address as an input.
5.2] The selection of MID server is done by passing the host as configured in the connection wsdl. Seems here we are not able to determine the host and thus the error.


1] Current WSDL URL configured may look like below:

2]  Please try updating the wsdl in the connection to use IP address like (e.g: instead DNS of name. You could create a new connection if necessary.
Work with your internal Admin team to determine the IP and update the SOAP message wsdl with the respective IP instead of the domain URL.

3) If DNS still has to be used, this could be achieved by creating a record in the table - cmdb_ci_dns_name for the URL to map it with the respective IP address. You could follow the below link for the same: