Calling java class from mock script
Hi, I have a mock soap service and want to do some magic with basic auth headers. When I try to import the java.utils.Base64 I get class not found errrors. Are the std java classes not on the classpath? Searching for this problem only gives examples of custom classes. The documentation and API suggest only a limited set of XML/SOAP/JSON/REST classes. Thnx, Wim-Jan Adding relevant piece of groovy: note that it is to help clarify the issue and imcomplete since I cut out or substituted sensitive info import java.utils.Base64 def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def alert = com.eviware.soapui.support.UISupport; log.info("------------- begin call -----------------------------"); def soapRequest = mockRequest.requestContent; def headers = mockRequest.requestHeaders; def incommingBasicAuth = headers.get("Authorization", "defaultAuth"); if (incommingBasicAuth == "defaultAuth") { log.info("no basicAuth header found!"); } else { String decodedAuth = Base64.getDecoder().decode; def uNamePw = decodedAuth.split(":"); log.info("basicAuth header for " + uNamePw + " found!"); } log.info("--- request will be forwarded to actual service ----") String basicAuth = ""; if (incommingBasicAuth == "defaultAuth") { log.info("Set hardcoded username,password"); String userCredentials = "someuser:somepw"; basicAuth = "Basic " + new String(Base64.getEncoder().encode(userCredentials.getBytes())); } else { log.info("use username password form incomming request"); basicAuth = incommingBasicAuth; } def soapUrl = new URL("https://somewebservice.nl/") def connection = soapUrl.openConnection() // insert the basic auth header connection.setRequestProperty("Authorization", basicAuth); connection.setRequestMethod("POST") connection.setRequestProperty("Content-Type", "text/html") connection.setRequestProperty("SOAPAction", "") connection.doOutput = true Writer writer = new OutputStreamWriter(connection.outputStream); writer.write(soapRequest) writer.flush() writer.close() connection.connect() def soapResponse = connection.content.text // work as proxy, i.e. just return response recieved from https://somewebservice.nl/ requestContext.responseMessage = soapResponseSolved2KViews0likes4Comments