public void actionPerformed(ActionEvent e) { try { MockResult mockResult = mockResponse.getMockResult(); mockResponse.evaluateScript(mockResult == null ? null : mockResult.getMockRequest()); StringToStringMap values = null; if (mockResponse.getMockResult() != null) { values = mockResponse.getMockResult().getMockRequest().getContext().toStringToStringMap(); } if (values == null || values.isEmpty()) { UISupport.showInfoMessage("No values were returned"); } else { String msg = "<html><body>Returned values:<br>"; for (String name : values.keySet()) { msg += XmlUtils.entitize(name) + " : " + XmlUtils.entitize(values.get(name)) + "<br>"; } msg += "</body></html>"; UISupport.showExtendedInfo( "Result", "Result of MockResponse Script", msg, new Dimension(500, 400)); } } catch (Throwable e1) { responseScriptEditor.selectError(e1.getMessage()); UISupport.showErrorMessage(e1.toString()); } }
private String initXPathNamespaces(String xpath) { if (declaredNamespaces != null && !declaredNamespaces.isEmpty()) { for (String prefix : declaredNamespaces.keySet()) { xpath = "declare namespace " + prefix + "='" + declaredNamespaces.get(prefix) + "';\n" + xpath; } } else if (!xpath.trim().startsWith("declare namespace")) { xpath = XmlUtils.declareXPathNamespaces(xmlObject) + xpath; } return xpath; }
private ConfigurationDocument createConfigFile(StringToStringMap values, Interface modelItem) { ConfigurationDocument configDocument = ConfigurationDocument.Factory.newInstance(); ConfigurationType config = configDocument.addNewConfiguration(); try { StringToStringMap nsMappings = StringToStringMap.fromXml(values.get(NAMESPACE_MAPPING)); if (!nsMappings.isEmpty()) { GlobalType global = config.addNewGlobal(); for (String namespace : nsMappings.keySet()) { PkgNSType entry = global.addNewPackageNamespace(); entry.setNamespace(namespace); entry.setPackage(nsMappings.get(namespace)); } } } catch (Exception e) { SoapUI.logError(e); } WsdlToJavaType wsdl2Java = config.addNewWsdlJava(); String wsdlUrl = getWsdlUrl(values, modelItem); try { new URL(wsdlUrl); wsdl2Java.setLocation(wsdlUrl); } catch (MalformedURLException e) { ((Element) wsdl2Java.getDomNode()).setAttribute("file", wsdlUrl); } if (values.getBoolean(UNWRAP)) wsdl2Java.setParameterStyle(ParameterStyle.BARE); else wsdl2Java.setParameterStyle(ParameterStyle.WRAPPED); if (values.get(EJB_LINK) != null && values.get(EJB_LINK).length() > 0) { WsxmlType webservices = wsdl2Java.addNewWebservices(); webservices.setEjbLink(values.get(EJB_LINK)); webservices.setAppend(values.getBoolean(APPEND)); } else if (values.get(SERVLET_LINK) != null && values.get(SERVLET_LINK).length() > 0) { WsxmlType webservices = wsdl2Java.addNewWebservices(); webservices.setServletLink(values.get(SERVLET_LINK)); webservices.setAppend(values.getBoolean(APPEND)); } String mappingFile = values.get(MAPPING).toString().trim(); if (mappingFile.length() > 0) { wsdl2Java.addNewMapping().setFile(mappingFile); } return configDocument; }