[jbosstools-commits] JBoss Tools SVN: r23756 - in trunk/ws/plugins/org.jboss.tools.ws.ui: .settings and 4 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Jul 27 17:05:30 EDT 2010
Author: bfitzpat
Date: 2010-07-27 17:05:29 -0400 (Tue, 27 Jul 2010)
New Revision: 23756
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistory.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/.classpath
trunk/ws/plugins/org.jboss.tools.ws.ui/.settings/org.eclipse.jdt.core.prefs
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/TesterWSDLUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java
Log:
[JBIDE-6702] [JBIDE-6693] Fixes to handle hand-typed entries and SOAP 1.2 message generation
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/.classpath
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/.classpath 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/.classpath 2010-07-27 21:05:29 UTC (rev 23756)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/.settings/org.eclipse.jdt.core.prefs 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/.settings/org.eclipse.jdt.core.prefs 2010-07-27 21:05:29 UTC (rev 23756)
@@ -1,8 +1,9 @@
-#Thu Apr 17 13:45:00 CST 2008
+#Mon Jul 26 15:15:24 MDT 2010
eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-07-27 21:05:29 UTC (rev 23756)
@@ -33,7 +33,8 @@
javax.xml.ws,
org.eclipse.ui.forms,
org.eclipse.emf.common,
- org.eclipse.jdt.ui
+ org.eclipse.jdt.ui,
+ org.eclipse.osgi
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.ui,
org.jboss.tools.ws.ui.messages,
@@ -42,7 +43,7 @@
org.jboss.tools.ws.ui.views,
org.jboss.tools.ws.ui.wizards
Bundle-Vendor: %PLUGIN_PROVIDER
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: javax.xml.ws,
org.eclipse.jst.javaee.web,
org.jboss.tools.ws.creation.core.commands,
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-07-27 21:05:29 UTC (rev 23756)
@@ -121,8 +121,13 @@
JAXRSWSTestView2_SaveResponseText_tooltip=Save to File
JAXRSWSTestView2_ShowInBrowser_Tooltip=Show in Browser
JAXRSWSTestView2_ShowRaw_Tooltip=Show Raw
+JAXRSWSTestView2_Text_Msg_May_Be_Out_of_Date=Should we replace the existing request message with one generated by your WSDL service/port/binding/operation selection?
+JAXRSWSTestView2_Title_Msg_May_Be_Out_of_Date=Message May Be Incorrect for Selected WSDL
ResultsXMLStorageInput_WS_Invocation_Results_Prefix=Web Service Invocation Results\:
WSDLBrowseDialog_Dialog_Title=Select WSDL
+WSDLBrowseDialog_Error_Msg_Invalid_URL=Invalid URL specified for WSDl.
+WSDLBrowseDialog_Error_Msg_Parse_Error=Encountered an error while parsing the selected WSDL.
+WSDLBrowseDialog_Error_Retrieving_WSDL=Error Retrieving WSDL
WSDLBrowseDialog_FS_Browse=File system...
WSDLBrowseDialog_Group_Title=Select the service operation:
WSDLBrowseDialog_Message=Select the source WSDL in the workspace or file system, or provide a URL from which to download the WSDL.
@@ -130,6 +135,7 @@
WSDLBrowseDialog_Port_Field=Port:
WSDLBrowseDialog_Service_Field=Service:
WSDLBrowseDialog_Status_Invalid_URL=Invalid URL
+WSDLBrowseDialog_Status_ParsingWSDLFromURL=Parsing WSDL from URL...
WSDLBrowseDialog_Status_WSDL_Unavailable=WSDL unavailable
WSDLBrowseDialog_Title=Specify the Source WSDL for the Web Service
WSDLBrowseDialog_URL_Browse=URL...
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-07-27 21:05:29 UTC (rev 23756)
@@ -152,9 +152,14 @@
public static String JAXRSWSTestView2_SaveResponseText_tooltip;
public static String JAXRSWSTestView2_ShowInBrowser_Tooltip;
public static String JAXRSWSTestView2_ShowRaw_Tooltip;
+ public static String JAXRSWSTestView2_Text_Msg_May_Be_Out_of_Date;
+ public static String JAXRSWSTestView2_Title_Msg_May_Be_Out_of_Date;
public static String ResultsXMLStorageInput_WS_Invocation_Results_Prefix;
public static String WSDLBrowseDialog_Dialog_Title;
+ public static String WSDLBrowseDialog_Error_Msg_Invalid_URL;
+ public static String WSDLBrowseDialog_Error_Msg_Parse_Error;
+ public static String WSDLBrowseDialog_Error_Retrieving_WSDL;
public static String WSDLBrowseDialog_FS_Browse;
public static String WSDLBrowseDialog_Group_Title;
public static String WSDLBrowseDialog_Message;
@@ -162,6 +167,7 @@
public static String WSDLBrowseDialog_Port_Field;
public static String WSDLBrowseDialog_Service_Field;
public static String WSDLBrowseDialog_Status_Invalid_URL;
+ public static String WSDLBrowseDialog_Status_ParsingWSDLFromURL;
public static String WSDLBrowseDialog_Status_WSDL_Unavailable;
public static String WSDLBrowseDialog_Title;
public static String WSDLBrowseDialog_URL_Browse;
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java 2010-07-27 21:05:29 UTC (rev 23756)
@@ -19,6 +19,7 @@
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Dispatch;
@@ -91,15 +92,23 @@
URL serviceURL = new URL (endpointurl); //"http://www.ecubicle.net/gsearch_rss.asmx"
QName serviceQName = new QName (ns, serviceName); // "http://www.ecubicle.net/webservices", "gsearch_rss"
Service s = Service.create(serviceURL, serviceQName);
+
+ boolean isSOAP12 = TesterWSDLUtils.isRequestBodySOAP12(body);
QName messageQName = new QName(ns, messageName); //"http://www.ecubicle.net/webservices", "gsearch_rssSoap"
Dispatch<SOAPMessage> d = s.createDispatch(messageQName, SOAPMessage.class, Mode.MESSAGE);
- d.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, actionurl); //"http://www.ecubicle.net/webservices/GetSearchResults");
MessageFactory mf = MessageFactory.newInstance();
+ if (isSOAP12) {
+ mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+ } else {
+ d.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
+ d.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, actionurl); //"http://www.ecubicle.net/webservices/GetSearchResults");
+ }
+
SOAPMessage m = mf.createMessage( null, new ByteArrayInputStream(body.getBytes()));
m.saveChanges();
-
+
Response<SOAPMessage> response = d.invokeAsync(m);
while (!response.isDone()){
//go off and do some work
@@ -138,18 +147,5 @@
//note interruptions
throw ie;
}
-// SOAPMessage o = d.invoke(m);
-//
-// ByteArrayOutputStream baos = new ByteArrayOutputStream();
-// o.writeTo(baos);
-// this.resultBody = baos.toString();
-// this.resultSOAPBody = o.getSOAPBody();
-//
-// if (d.getResponseContext() != null) {
-// Object responseHeaders = d.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
-// if ( responseHeaders != null && responseHeaders instanceof Map) {
-// this.resultHeaders = (Map<String, String>) responseHeaders;
-// }
-// }
}
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/TesterWSDLUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/TesterWSDLUtils.java 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/TesterWSDLUtils.java 2010-07-27 21:05:29 UTC (rev 23756)
@@ -35,6 +35,7 @@
import javax.wsdl.Service;
import javax.wsdl.Types;
import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.schema.Schema;
import javax.wsdl.extensions.schema.SchemaImport;
import javax.wsdl.extensions.soap.SOAPAddress;
@@ -91,6 +92,12 @@
"javax.wsdl.factory.DefinitionFactory"; //$NON-NLS-1$
private final static String PRIVATE_DEF_FACTORY_CLASS =
"org.apache.wsif.wsdl.WSIFWSDLFactoryImpl"; //$NON-NLS-1$
+
+ public final static String SOAP_NS_URI = "http://schemas.xmlsoap.org/soap/envelope/"; //$NON-NLS-1$
+ public final static String SOAP12_ENVELOPE_NS_URI = "http://www.w3.org/2003/05/soap-envelope"; //$NON-NLS-1$
+ public final static String SOAP12_NS_URI = "http://schemas.xmlsoap.org/wsdl/soap12/"; //$NON-NLS-1$
+ public final static String SOAP12_PREFIX = "soap12"; //$NON-NLS-1$
+ public final static String SOAP_PREFIX = "soap"; //$NON-NLS-1$
public static Definition readWSDLURL(URL contextURL, String wsdlLoc) throws WSDLException {
Properties props = System.getProperties();
@@ -115,7 +122,7 @@
return def;
}
- public static Definition readWSDLURL(URL contextURL) throws WSDLException {
+ public static Definition readWSDLURL(URL contextURL) throws WSDLException, NullPointerException {
Properties props = System.getProperties();
String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
@@ -138,6 +145,35 @@
return def;
}
+ public static boolean isSOAP12 (Definition wsdlDefinition, String serviceName, String portName) {
+ Map<?, ?> services = wsdlDefinition.getServices();
+ Set<?> serviceKeys = services.keySet();
+ for( Iterator<?> it = serviceKeys.iterator(); it.hasNext(); ) {
+ QName serviceKey = (QName) it.next();
+ if (serviceName != null && serviceKey.getLocalPart().contentEquals(serviceName)) {
+ Service service = (Service) services.get( serviceKey );
+ Map<?, ?> ports = service.getPorts();
+ Set<?> portKeys = ports.keySet();
+ for( Iterator<?> it2 = portKeys.iterator(); it2.hasNext(); ) {
+ String portKey = (String) it2.next();
+ if (portName != null && portKey.contentEquals(portName)) {
+ Port port = (Port) ports.get( portKey );
+ List<?> extElements = port.getExtensibilityElements();
+ for (Iterator<?> it3 = extElements.iterator(); it3.hasNext(); ) {
+ ExtensibilityElement element = (ExtensibilityElement) it3.next();
+ String nsURI = element.getElementType().getNamespaceURI();
+ if (nsURI.contentEquals(SOAP12_NS_URI)) {
+ return true;
+ }
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
public static String getSampleSOAPInputMessage ( Definition wsdlDefinition, String serviceName, String portName, String bindingName, String opName ) {
Map<?, ?> services = wsdlDefinition.getServices();
Set<?> serviceKeys = services.keySet();
@@ -734,4 +770,12 @@
}
return null;
}
+
+ public static boolean isRequestBodySOAP12 ( String body ) {
+ boolean isSOAP12 = false;
+ if (body.indexOf('<' + SOAP12_PREFIX + ":Envelope") > -1) { //$NON-NLS-1$
+ isSOAP12 = true;
+ }
+ return isSOAP12;
+ }
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2010-07-27 21:05:29 UTC (rev 23756)
@@ -10,18 +10,36 @@
******************************************************************************/
package org.jboss.tools.ws.ui.views;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import java.util.Map.Entry;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Operation;
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import org.apache.axis.soap.MessageFactoryImpl;
import org.apache.axis.utils.XMLUtils;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -47,6 +65,8 @@
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionEvent;
@@ -140,7 +160,7 @@
private MenuItem copyResultHeaderMenuAction;
private String[] serviceNSMessage = null;
- private String actionText = null;
+// private String actionText = null;
private FormToolkit toolkit;
private ScrolledForm form;
@@ -159,6 +179,9 @@
private ScrolledPageBook pageBook;
private ShowRawAction rawAction;
private ShowInBrowserAction browserAction;
+
+ private TestHistory history = new TestHistory();
+ private TestHistoryEntry currentHistoryEntry = null;
/**
* The constructor.
@@ -298,7 +321,212 @@
return JAX_WS;
return JAX_RS;
}
+
+ private boolean getWSDLSpecifics( String opName ) {
+
+ if (opName != null) {
+ String opNameInBody = getOpNameFromRequestBody();
+ if (opNameInBody != null) {
+ boolean isRequestSOAP12 =
+ TesterWSDLUtils.isRequestBodySOAP12(getCurrentHistoryEntry().getBody());
+ String urlText = urlCombo.getText();
+ if (urlText != null) {
+ try {
+ URL tempURL = new URL(urlText);
+ Definition wsdlDef =
+ TesterWSDLUtils.readWSDLURL(tempURL);
+ Map<?, ?> bindings = wsdlDef.getAllBindings();
+ Iterator<?> iter = bindings.entrySet().iterator();
+ while (iter.hasNext()) {
+ Entry<?, ?> mapEntry = (Entry<?, ?>) iter.next();
+ Binding binding = (Binding) mapEntry.getValue();
+ Iterator<?> iter2 = binding.getBindingOperations().iterator();
+ while (iter2.hasNext()) {
+ BindingOperation bindOp = (BindingOperation) iter2.next();
+ if (bindOp.getName().contentEquals(opNameInBody)) {
+ Iterator<?> iter3 = bindOp.getExtensibilityElements().iterator();
+ while (iter3.hasNext()) {
+ ExtensibilityElement extEl = (ExtensibilityElement) iter3.next();
+ if (extEl.getElementType().getLocalPart().contentEquals("operation")) { //$NON-NLS-1$
+ String actionURL = null;
+ String[] nsArray = null;
+ if (!isRequestSOAP12 && extEl instanceof SOAPOperation) {
+ SOAPOperation soapOp = (SOAPOperation) extEl;
+ actionURL = soapOp.getSoapActionURI();
+ } else if (isRequestSOAP12 && extEl instanceof SOAP12Operation) {
+ SOAP12Operation soapOp = (SOAP12Operation) extEl;
+ actionURL = soapOp.getSoapActionURI();
+ }
+ if (actionURL != null) {
+ PortType portType = binding.getPortType();
+ String ns = portType.getQName().getNamespaceURI();
+
+ QName bindingQName = binding.getQName();
+ Map<?,?> services = wsdlDef.getAllServices();
+ Iterator<?> iter4 = services.entrySet().iterator();
+ while (iter4.hasNext()) {
+ Entry<?, ?> serviceEntry = (Entry<?, ?>) iter4.next();
+ Service service = (Service) serviceEntry.getValue();
+ Iterator<?> iter5 = service.getPorts().entrySet().iterator();
+ while (iter5.hasNext()) {
+ Entry<?, ?> portEntry = (Entry<?, ?>) iter5.next();
+ Port port = (Port) portEntry.getValue();
+ if (port.getBinding().getQName().equals(bindingQName)) {
+ String serviceName = service.getQName().getLocalPart();
+ String portName = port.getName();
+ nsArray = new String[] {ns, serviceName, portName};
+ if (actionURL != null && nsArray != null) {
+ getCurrentHistoryEntry().setAction(actionURL);
+ getCurrentHistoryEntry().setServiceNSMessage(nsArray);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (WSDLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ WSDLBrowseDialog wbDialog = new WSDLBrowseDialog(getSite().getShell());
+ if (urlCombo.getText().length() > 0) {
+ wbDialog.setURLText(urlCombo.getText());
+ }
+ if (opName != null) {
+ wbDialog.setInitialOperationTextValue(opName);
+ }
+ int rtnCode = wbDialog.open();
+ if (rtnCode == Window.OK){
+
+ getCurrentHistoryEntry().setServiceNSMessage(null);
+ getCurrentHistoryEntry().setAction(null);
+ getCurrentHistoryEntry().setWsdlDef(null);
+ getCurrentHistoryEntry().setServiceName(null);
+ getCurrentHistoryEntry().setPortName(null);
+ getCurrentHistoryEntry().setBindingName(null);
+ getCurrentHistoryEntry().setOperationName(null);
+ serviceNSMessage = null;
+// actionText = null;
+
+ Definition wsdlDef = wbDialog.getWSDLDefinition();
+ getCurrentHistoryEntry().setWsdlDef(wsdlDef);
+ getCurrentHistoryEntry().setServiceName(wbDialog.getServiceTextValue());
+ getCurrentHistoryEntry().setPortName(wbDialog.getPortTextValue());
+ getCurrentHistoryEntry().setBindingName(wbDialog.getBindingValue());
+ getCurrentHistoryEntry().setOperationName(wbDialog.getOperationTextValue());
+ getCurrentHistoryEntry().setUrl(wbDialog.getWSDLText());
+ urlCombo.setText(wbDialog.getWSDLText());
+
+ String output = TesterWSDLUtils.getSampleSOAPInputMessage(wsdlDef,
+ wbDialog.getServiceTextValue(),
+ wbDialog.getPortTextValue(),
+ wbDialog.getBindingValue(),
+ wbDialog.getOperationTextValue());
+
+ String endpointURL = TesterWSDLUtils.getEndpointURL(wsdlDef,
+ wbDialog.getServiceTextValue(),
+ wbDialog.getPortTextValue(),
+ wbDialog.getBindingValue(),
+ wbDialog.getOperationTextValue());
+ getCurrentHistoryEntry().setUrl(endpointURL);
+
+ String actionURL = TesterWSDLUtils.getActionURL(wsdlDef,
+ wbDialog.getServiceTextValue(),
+ wbDialog.getPortTextValue(),
+ wbDialog.getBindingValue(),
+ wbDialog.getOperationTextValue());
+ getCurrentHistoryEntry().setAction(actionURL);
+
+ serviceNSMessage = TesterWSDLUtils.getNSServiceNameAndMessageNameArray(wsdlDef,
+ wbDialog.getServiceTextValue(),
+ wbDialog.getPortTextValue(),
+ wbDialog.getBindingValue(),
+ wbDialog.getOperationTextValue());
+ getCurrentHistoryEntry().setServiceNSMessage(serviceNSMessage);
+
+ boolean isSOAP12 = TesterWSDLUtils.isSOAP12(wsdlDef,
+ wbDialog.getServiceTextValue(),
+ wbDialog.getPortTextValue());
+ getCurrentHistoryEntry().setSOAP12(isSOAP12);
+
+ String soapIn = generateSampleSOAP(output, isSOAP12);
+ if (opName != null) {
+ if (bodyText.getText().length() > 0) {
+
+ String opNameInBody = getOpNameFromRequestBody();
+ if (opNameInBody == null) {
+ bodyText.setText(soapIn);
+ getCurrentHistoryEntry().setBody(soapIn);
+ getCurrentHistoryEntry().setAction(actionURL);
+ } else if (opNameInBody.contentEquals(getCurrentHistoryEntry().getOperationName())) {
+ // ignore
+ } else {
+ if (MessageDialog.openQuestion(getSite().getShell(),
+ JBossWSUIMessages.JAXRSWSTestView2_Title_Msg_May_Be_Out_of_Date,
+ JBossWSUIMessages.JAXRSWSTestView2_Text_Msg_May_Be_Out_of_Date)) {
+
+ bodyText.setText(soapIn);
+ getCurrentHistoryEntry().setBody(soapIn);
+ getCurrentHistoryEntry().setAction(actionURL);
+
+ }
+ }
+ }
+// if (MessageDialog.openQuestion(getSite().getShell(),
+// JBossWSUIMessages.JAXRSWSTestView2_Title_Msg_May_Be_Out_of_Date,
+// JBossWSUIMessages.JAXRSWSTestView2_Text_Msg_May_Be_Out_of_Date)) {
+//
+// bodyText.setText(soapIn);
+// getCurrentHistoryEntry().setBody(soapIn);
+// getCurrentHistoryEntry().setAction(actionURL);
+//
+// }
+ } else if (bodyText.getText().length() > 0) {
+
+ String opNameInBody = getOpNameFromRequestBody();
+ boolean isRequestSOAP12 = TesterWSDLUtils.isRequestBodySOAP12(getCurrentHistoryEntry().getBody());
+
+ if (opNameInBody == null || isSOAP12 != isRequestSOAP12 ) {
+ bodyText.setText(soapIn);
+ getCurrentHistoryEntry().setBody(soapIn);
+ getCurrentHistoryEntry().setAction(actionURL);
+ } else if (opNameInBody.contentEquals(getCurrentHistoryEntry().getOperationName())) {
+ // ignore
+ } else {
+ if (MessageDialog.openQuestion(getSite().getShell(),
+ JBossWSUIMessages.JAXRSWSTestView2_Title_Msg_May_Be_Out_of_Date,
+ JBossWSUIMessages.JAXRSWSTestView2_Text_Msg_May_Be_Out_of_Date)) {
+
+ bodyText.setText(soapIn);
+ getCurrentHistoryEntry().setBody(soapIn);
+ getCurrentHistoryEntry().setAction(actionURL);
+
+ }
+ }
+ }
+
+// urlCombo.setText(endpointURL);
+// actionText = actionURL;
+
+ setControlsForWSType(getCurrentTestType());
+ setControlsForMethodType(methodCombo.getText());
+ setControlsForSelectedURL();
+ return true;
+ }
+ return false;
+ }
+
private void createURLAndToolbar( ) {
urlCombo = new Combo(form.getBody(), SWT.BORDER | SWT.DROP_DOWN);
GridData gdURL = new GridData(SWT.FILL, SWT.NONE, true, false);
@@ -311,6 +539,8 @@
public void keyReleased(KeyEvent e) {
setControlsForSelectedURL();
+ getCurrentHistoryEntry().setUrl(urlCombo.getText());
+ getCurrentHistoryEntry().setAction(null);
if (e.keyCode == SWT.CR && e.stateMask == SWT.CTRL) {
handleTest(getCurrentTestType());
}
@@ -321,6 +551,8 @@
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
+ getCurrentHistoryEntry().setUrl(urlCombo.getText());
+ getCurrentHistoryEntry().setAction(null);
setControlsForSelectedURL();
}
});
@@ -347,6 +579,7 @@
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
+ getCurrentHistoryEntry().setMethod(methodCombo.getText());
setControlsForWSType(getCurrentTestType());
setControlsForMethodType(methodCombo.getText());
setControlsForSelectedURL();
@@ -363,40 +596,7 @@
openWSDLToolItem.setToolTipText(JBossWSUIMessages.JAXRSWSTestView2_GetFromWSDL_Tooltip);
openWSDLToolItem.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
- WSDLBrowseDialog wbDialog = new WSDLBrowseDialog(getSite().getShell());
- int rtnCode = wbDialog.open();
- if (rtnCode == Window.OK){
- serviceNSMessage = null;
- actionText = null;
- Definition wsdlDef = wbDialog.getWSDLDefinition();
- String output = TesterWSDLUtils.getSampleSOAPInputMessage(wsdlDef,
- wbDialog.getServiceTextValue(),
- wbDialog.getPortTextValue(),
- wbDialog.getBindingValue(),
- wbDialog.getOperationTextValue());
- String endpointURL = TesterWSDLUtils.getEndpointURL(wsdlDef,
- wbDialog.getServiceTextValue(),
- wbDialog.getPortTextValue(),
- wbDialog.getBindingValue(),
- wbDialog.getOperationTextValue());
- String actionURL = TesterWSDLUtils.getActionURL(wsdlDef,
- wbDialog.getServiceTextValue(),
- wbDialog.getPortTextValue(),
- wbDialog.getBindingValue(),
- wbDialog.getOperationTextValue());
- serviceNSMessage = TesterWSDLUtils.getNSServiceNameAndMessageNameArray(wsdlDef,
- wbDialog.getServiceTextValue(),
- wbDialog.getPortTextValue(),
- wbDialog.getBindingValue(),
- wbDialog.getOperationTextValue());
- String soapIn = generateSampleSOAP(output);
- bodyText.setText(soapIn);
- urlCombo.setText(endpointURL);
- actionText = actionURL;
- setControlsForWSType(getCurrentTestType());
- setControlsForMethodType(methodCombo.getText());
- setControlsForSelectedURL();
- }
+ getWSDLSpecifics(null);
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
@@ -437,6 +637,12 @@
ExpandableComposite.CLIENT_INDENT);
ec.setText(JBossWSUIMessages.JAXRSWSTestView2_Headers_Section);
dlsList = new DelimitedStringList(ec, SWT.None, false, false);
+ dlsList.addChangeListener(new ChangeListener(){
+ public void stateChanged(ChangeEvent e) {
+ getCurrentHistoryEntry().setHeaders(dlsList.getSelection());
+ getCurrentHistoryEntry().setAction(null);
+ }
+ });
ec.setClient(dlsList);
toolkit.adapt(dlsList);
GridData gd2 = new GridData(SWT.FILL, SWT.FILL, true, false);
@@ -449,6 +655,12 @@
ec3.setText(JBossWSUIMessages.JAXRSWSTestView2_Parameters_Section);
parmsList = new DelimitedStringList(ec3, SWT.None, false, false);
parmsList.setShowUpDown(false);
+ parmsList.addChangeListener(new ChangeListener(){
+ public void stateChanged(ChangeEvent e) {
+ getCurrentHistoryEntry().setParms(parmsList.getSelection());
+ getCurrentHistoryEntry().setAction(null);
+ }
+ });
ec3.setClient(parmsList);
toolkit.adapt(parmsList);
GridData gd4 = new GridData(SWT.FILL, SWT.FILL, true, false);
@@ -461,6 +673,23 @@
ExpandableComposite.EXPANDED);
ec5.setText(JBossWSUIMessages.JAXRSWSTestView2_BodyText_Section);
bodyText = toolkit.createText(ec5, EMPTY_STRING, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
+ bodyText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ getCurrentHistoryEntry().setBody(bodyText.getText());
+// getCurrentHistoryEntry().setAction(null);
+ }
+ });
+ bodyText.addKeyListener(new KeyListener() {
+ public void keyPressed(KeyEvent e) {
+ }
+
+ public void keyReleased(KeyEvent e) {
+ getCurrentHistoryEntry().setBody(bodyText.getText());
+ if (e.keyCode == SWT.CR && e.stateMask == SWT.CTRL) {
+ handleTest(getCurrentTestType());
+ }
+ }
+ });
ec5.setClient(bodyText);
GridData gd9 = new GridData(SWT.FILL, SWT.FILL, true, true);
gd9.minimumHeight = 200;
@@ -470,6 +699,13 @@
section.addExpansionListener(new FormExpansionAdapter());
section.setClient(sectionClient);
}
+
+ private TestHistoryEntry getCurrentHistoryEntry() {
+ if (this.currentHistoryEntry == null) {
+ this.currentHistoryEntry = new TestHistoryEntry();
+ }
+ return this.currentHistoryEntry;
+ }
private void createResponseSide ( SashForm sashForm ) {
Section section2 = toolkit.createSection(sashForm,
@@ -731,18 +967,24 @@
super.dispose();
}
- private String generateSampleSOAP ( String innerText ) {
+ private String generateSampleSOAP ( String innerText, boolean isSOAP12 ) {
+ String prefix = TesterWSDLUtils.SOAP_PREFIX;
+ String soapURI = TesterWSDLUtils.SOAP_NS_URI;
+ if (isSOAP12) {
+ prefix = TesterWSDLUtils.SOAP12_PREFIX;
+ soapURI = TesterWSDLUtils.SOAP12_ENVELOPE_NS_URI;
+ }
String soapIn = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" + //$NON-NLS-1$
- "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " + //$NON-NLS-1$
+ "<" + prefix + ":Envelope xmlns:" + prefix + "=\"" + soapURI + "\" " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + //$NON-NLS-1$
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + //$NON-NLS-1$
">\n" + //$NON-NLS-1$
- "<soap:Body>\n";//$NON-NLS-1$
+ "<" + prefix + ":Body>\n";//$NON-NLS-1$ //$NON-NLS-2$
if (innerText != null)
soapIn = soapIn + innerText;
soapIn = soapIn +
- "</soap:Body>\n" + //$NON-NLS-1$
- "</soap:Envelope>"; //$NON-NLS-1$
+ "</" + prefix + ":Body>\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "</" + prefix + ":Envelope>"; //$NON-NLS-1$ //$NON-NLS-2$
return soapIn;
}
@@ -827,7 +1069,7 @@
dlsList.setEnabled(false);
String emptySOAP =
- generateSampleSOAP(null);
+ generateSampleSOAP(null, false);
emptySOAP = WSTestUtils.addNLsToXML(emptySOAP);
if (bodyText.getText().trim().length() == 0) {
@@ -848,6 +1090,26 @@
setMenusForCurrentState();
}
+ private String getOpNameFromRequestBody () {
+ MessageFactory factory = new MessageFactoryImpl();
+ String lookForOpName = null;
+ try {
+ SOAPMessage message =
+ factory.createMessage(null, new ByteArrayInputStream(getCurrentHistoryEntry().getBody().getBytes()));
+ SOAPBody body = message.getSOAPBody();
+ Iterator<?> elements = body.getChildElements();
+ if (elements.hasNext()) {
+ Element element = (Element) elements.next();
+ lookForOpName = element.getNodeName();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (SOAPException e) {
+ e.printStackTrace();
+ }
+ return lookForOpName;
+ }
+
/*
* Actually perform the test based on which type of activity it is
*/
@@ -861,6 +1123,19 @@
return;
}
+ String lookForOpName = null;
+
+ if (wsTech.contentEquals(JAX_WS)) {
+ lookForOpName = getOpNameFromRequestBody();
+
+ if (getCurrentHistoryEntry().getAction() == null ) {
+ boolean result = getWSDLSpecifics(lookForOpName);
+ if (!result)
+ return;
+ }
+
+ }
+
if (urlCombo.getItemCount() > 0) {
java.util.List<String> aList = Arrays.asList(urlCombo.getItems());
if (!aList.contains(urlCombo.getText())) {
@@ -869,13 +1144,22 @@
} else {
urlCombo.add(urlCombo.getText());
}
+
+ getCurrentHistoryEntry().setWsTech(wsTech);
+
+ final String url = getCurrentHistoryEntry().getUrl();
+ final String action = getCurrentHistoryEntry().getAction();
+ final String body = getCurrentHistoryEntry().getBody();
+ final String method = getCurrentHistoryEntry().getMethod();
+ final String headers = getCurrentHistoryEntry().getHeaders();
+ final String parms = getCurrentHistoryEntry().getParms();
- final String url = urlCombo.getText();
- final String action = actionText;
- final String body = bodyText.getText();
- final String method = methodCombo.getText();
- final String headers = dlsList.getSelection();
- final String parms = parmsList.getSelection();
+// final String url = urlCombo.getText();
+// final String action = actionText;
+// final String body = bodyText.getText();
+// final String method = methodCombo.getText();
+// final String headers = dlsList.getSelection();
+// final String parms = parmsList.getSelection();
Job aJob = new Job(JBossWSUIMessages.JAXRSWSTestView_Invoking_WS_Status) {
protected IStatus run(IProgressMonitor monitor) {
@@ -904,11 +1188,13 @@
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
if (status.getResultsText() != null) {
+ getCurrentHistoryEntry().setResultText(status.getResultsText());
JAXRSWSTestView2.this.resultsText.setText(status.getResultsText());
JAXRSWSTestView2.this.resultsBrowser.setText(status.getResultsText());
JAXRSWSTestView2.this.form.reflow(true);
}
else if (status.getMessage() != null) {
+ getCurrentHistoryEntry().setResultText(status.getMessage());
JAXRSWSTestView2.this.resultsText.setText(status.getMessage());
JAXRSWSTestView2.this.resultsBrowser.setText(status.getMessage());
JAXRSWSTestView2.this.form.reflow(true);
@@ -921,6 +1207,8 @@
resultHeadersList.add(headers[i]);
}
}
+ getCurrentHistoryEntry().setResultHeadersList(headers);
+ history.getEntries().add(getCurrentHistoryEntry());
}
});
}
@@ -945,6 +1233,7 @@
monitor.worked(10);
JAXWSTester2 tester = new JAXWSTester2();
boolean itRan = false;
+ serviceNSMessage = getCurrentHistoryEntry().getServiceNSMessage();
while (!monitor.isCanceled()) {
try {
if (!itRan && serviceNSMessage != null && serviceNSMessage.length == 3) {
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistory.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistory.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistory.java 2010-07-27 21:05:29 UTC (rev 23756)
@@ -0,0 +1,16 @@
+package org.jboss.tools.ws.ui.views;
+
+import java.util.Stack;
+
+public class TestHistory {
+
+ private Stack<TestHistoryEntry> entries = null;
+
+ public TestHistory() {
+ entries = new Stack<TestHistoryEntry>();
+ }
+
+ public Stack<TestHistoryEntry> getEntries() {
+ return entries;
+ }
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java 2010-07-27 21:05:29 UTC (rev 23756)
@@ -0,0 +1,174 @@
+package org.jboss.tools.ws.ui.views;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+
+import org.jboss.tools.ws.ui.JBossWSUIPlugin;
+import org.jboss.tools.ws.ui.utils.TesterWSDLUtils;
+
+public class TestHistoryEntry {
+
+ private String url;
+ private String action;
+ private String body;
+ private String method;
+ private String headers;
+ private String parms;
+ private String[] resultHeadersList;
+ private String resultText;
+ private String wsTech;
+ private String serviceName;
+ private String portName;
+ private String bindingName;
+ private String operationName;
+// private String wsMethod;
+ private Definition wsdlDef = null;
+ private String[] serviceNSMessage = null;
+ private boolean isSOAP12 = false;
+
+ public TestHistoryEntry() {
+ // empty
+ }
+
+ public String getUrl() {
+ return url;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ public void setResultHeadersList(String[] resultHeadersList) {
+ this.resultHeadersList = resultHeadersList;
+ }
+
+ public String[] getResultHeadersList() {
+ return resultHeadersList;
+ }
+
+ public String getAction() {
+ return action;
+ }
+ public void setAction(String action) {
+ this.action = action;
+ }
+ public String getBody() {
+ return body;
+ }
+ public void setBody(String body) {
+ this.body = body;
+ }
+ public String getMethod() {
+ return method;
+ }
+ public void setMethod(String method) {
+ this.method = method;
+ }
+ public String getHeaders() {
+ return headers;
+ }
+ public void setHeaders(String headers) {
+ this.headers = headers;
+ }
+ public String getParms() {
+ return parms;
+ }
+ public void setParms(String parms) {
+ this.parms = parms;
+ }
+
+ public void setResultText(String resultText) {
+ this.resultText = resultText;
+ }
+
+ public String getResultText() {
+ return resultText;
+ }
+
+ public void setWsTech(String wsTech) {
+ this.wsTech = wsTech;
+ }
+
+ public String getWsTech() {
+ return wsTech;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getPortName() {
+ return portName;
+ }
+
+ public void setPortName(String portName) {
+ this.portName = portName;
+ }
+
+ public String getBindingName() {
+ return bindingName;
+ }
+
+ public void setBindingName(String bindingName) {
+ this.bindingName = bindingName;
+ }
+
+ public String getOperationName() {
+ return operationName;
+ }
+
+ public void setOperationName(String operationName) {
+ this.operationName = operationName;
+ }
+
+// public void setWsMethod(String wsMethod) {
+// this.wsMethod = wsMethod;
+// }
+//
+// public String getWsMethod() {
+// return wsMethod;
+// }
+
+ public void setWsdlDef(Definition wsdlDef) {
+ this.wsdlDef = wsdlDef;
+ }
+
+ public Definition getWsdlDef() {
+ if (this.wsdlDef == null && this.url != null && this.url.length() > 0) {
+ try {
+ URL tempURL = new URL(this.url);
+ wsdlDef =
+ TesterWSDLUtils.readWSDLURL(tempURL);
+ } catch (MalformedURLException e) {
+ JBossWSUIPlugin.log(e);
+ return null;
+ } catch (WSDLException e) {
+ JBossWSUIPlugin.log(e);
+ return null;
+ }
+ }
+ return wsdlDef;
+ }
+
+ public void setServiceNSMessage(String[] serviceNSMessage) {
+ this.serviceNSMessage = serviceNSMessage;
+ }
+
+ public String[] getServiceNSMessage() {
+ return serviceNSMessage;
+ }
+
+ public void setSOAP12(boolean isSOAP12) {
+ this.isSOAP12 = isSOAP12;
+ }
+
+ public boolean isSOAP12() {
+ return isSOAP12;
+ }
+
+}
Property changes on: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/TestHistoryEntry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java 2010-07-27 21:01:19 UTC (rev 23755)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/WSDLBrowseDialog.java 2010-07-27 21:05:29 UTC (rev 23756)
@@ -11,6 +11,7 @@
package org.jboss.tools.ws.ui.views;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -31,11 +32,16 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -49,6 +55,7 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
@@ -80,6 +87,7 @@
private String serviceTextValue = null;
private String portTextValue = null;
private String operationTextValue = null;
+ private String initialOperationTextValue = null;
private String bindingValue = null;
private Definition wsdlDefinition = null;
@@ -123,10 +131,18 @@
public String getOperationTextValue() {
return operationTextValue;
}
+
+ public void setInitialOperationTextValue( String value ) {
+ initialOperationTextValue = value;
+ }
public Definition getWSDLDefinition(){
return this.wsdlDefinition;
}
+
+ public void setURLText(String urlText) {
+ wsdlTextValue = urlText;
+ }
@SuppressWarnings("unchecked")
@Override
@@ -167,11 +183,14 @@
locationCombo.setLayoutData(gridData);
locationCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent arg0) {
- IStatus status = validate();
+ setMessage(JBossWSUIMessages.WSDLBrowseDialog_Message);
+ IStatus status = validate(false);
if (status != Status.OK_STATUS) {
+ setMessage(status.getMessage(), IMessageProvider.WARNING);
if (showServicePortOperaton)
setGroupEnabled(false);
} else {
+ setMessage(JBossWSUIMessages.WSDLBrowseDialog_Message);
if (showServicePortOperaton)
setGroupEnabled(true);
}
@@ -305,16 +324,21 @@
if (rtnCode == Window.OK) {
locationCombo.setText(inDialog.getValue());
try {
- URL testURL = new URL(inDialog.getValue());
+ final URL testURL = new URL(inDialog.getValue());
locationCombo.setText(testURL.toExternalForm());
- wsdlDefinition =
- TesterWSDLUtils.readWSDLURL(testURL);
- if (showServicePortOperaton)
- updateServiceCombo();
+ IStatus status = parseWSDLFromURL(testURL, true);
+ if (status != null && !status.isOK()) {
+ setMessage(status.getMessage());
+ } else {
+ setMessage(JBossWSUIMessages.WSDLBrowseDialog_Message);
+ if (showServicePortOperaton)
+ updateServiceCombo();
+ }
} catch (MalformedURLException e) {
JBossWSUIPlugin.log(e);
- } catch (WSDLException e) {
- JBossWSUIPlugin.log(e);
+ ErrorDialog.openError(getShell(), JBossWSUIMessages.WSDLBrowseDialog_Error_Retrieving_WSDL,
+ JBossWSUIMessages.WSDLBrowseDialog_Error_Msg_Invalid_URL,
+ StatusUtils.errorStatus(e));
}
}
}
@@ -377,9 +401,71 @@
}
mainComposite.pack();
-
+
return mainComposite;
}
+
+ class ReadWSDLProgress implements IRunnableWithProgress {
+
+ private URL testURL = null;
+ private IStatus result = null;
+
+ public void setTestURL ( URL url ) {
+ this.testURL = url;
+ }
+
+ public IStatus getResult() {
+ return this.result;
+ }
+
+ public void run(IProgressMonitor monitor) {
+ monitor
+ .beginTask(JBossWSUIMessages.WSDLBrowseDialog_Status_ParsingWSDLFromURL,
+ 100);
+ try {
+ wsdlDefinition =
+ TesterWSDLUtils.readWSDLURL(testURL);
+ } catch (WSDLException e) {
+ result = StatusUtils.errorStatus(
+ JBossWSUIMessages.WSDLBrowseDialog_Error_Msg_Parse_Error, e);
+ }
+ monitor.done();
+ }
+ }
+
+ private IStatus parseWSDLFromURL ( final URL testURL, boolean showProgress) {
+
+ if (showProgress) {
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
+ try {
+ ReadWSDLProgress readWSDLProgress = new ReadWSDLProgress();
+ readWSDLProgress.setTestURL(testURL);
+ dialog.run(true, true, readWSDLProgress);
+ return readWSDLProgress.getResult();
+ } catch (InvocationTargetException e) {
+ return StatusUtils.errorStatus(
+ JBossWSUIMessages.WSDLBrowseDialog_Error_Msg_Parse_Error, e);
+ } catch (InterruptedException e) {
+ return StatusUtils.errorStatus(
+ JBossWSUIMessages.WSDLBrowseDialog_Error_Msg_Parse_Error, e);
+ } catch (NullPointerException e) {
+ return StatusUtils.errorStatus(
+ JBossWSUIMessages.WSDLBrowseDialog_Error_Msg_Parse_Error, e);
+ }
+ } else {
+ try {
+ wsdlDefinition =
+ TesterWSDLUtils.readWSDLURL(testURL);
+ } catch (WSDLException e) {
+ return StatusUtils.errorStatus(
+ JBossWSUIMessages.WSDLBrowseDialog_Error_Msg_Parse_Error, e);
+ } catch (NullPointerException e) {
+ return StatusUtils.errorStatus(
+ JBossWSUIMessages.WSDLBrowseDialog_Error_Msg_Parse_Error, e);
+ }
+ }
+ return Status.OK_STATUS;
+ }
private void updateOperationList(){
if (portCombo.getSelectionIndex() > -1) {
@@ -402,7 +488,19 @@
opList.setData(operation.getName(), operation);
}
if (opList.getItemCount() > 0) {
- opList.select(0);
+ boolean foundIt = false;
+ if (initialOperationTextValue != null) {
+ String[] thelist = opList.getItems();
+ for (int i = 0; i < thelist.length; i++) {
+ if (thelist[i].contentEquals(initialOperationTextValue)) {
+ opList.select(i);
+ foundIt = true;
+ break;
+ }
+ }
+ }
+ if (!foundIt)
+ opList.select(0);
this.operationTextValue = opList.getSelection()[0];
}
}
@@ -444,17 +542,19 @@
portCombo.removeAll();
opList.removeAll();
- Iterator<?> iter = wsdlDefinition.getServices().values().iterator();
- while (iter.hasNext()) {
- Service service = (Service) iter.next();
- serviceCombo.add(service.getQName().getLocalPart());
- serviceCombo.setData(service.getQName().getLocalPart(), service);
+ if (wsdlDefinition != null && wsdlDefinition.getServices() != null && !wsdlDefinition.getServices().isEmpty()) {
+ Iterator<?> iter = wsdlDefinition.getServices().values().iterator();
+ while (iter.hasNext()) {
+ Service service = (Service) iter.next();
+ serviceCombo.add(service.getQName().getLocalPart());
+ serviceCombo.setData(service.getQName().getLocalPart(), service);
+ }
+ if (serviceCombo.getItemCount() > 0) {
+ serviceCombo.select(0);
+ serviceTextValue = serviceCombo.getText();
+ }
+ updatePortCombo();
}
- if (serviceCombo.getItemCount() > 0) {
- serviceCombo.select(0);
- serviceTextValue = serviceCombo.getText();
- }
- updatePortCombo();
}
@Override
@@ -484,18 +584,23 @@
}
}
- private IStatus validate(){
+ private IStatus validate(boolean showProgress){
String urlText = locationCombo.getText();
try {
- URL testURL = new URL(urlText);
- wsdlDefinition =
- TesterWSDLUtils.readWSDLURL(testURL);
+ final URL testURL = new URL(urlText);
+ IStatus status = parseWSDLFromURL(testURL, false);
+ if (status != null && !status.isOK()) {
+ return status;
+ }
+// parseWSDLFromURL(testURL);
+// wsdlDefinition =
+// TesterWSDLUtils.readWSDLURL(testURL);
if (showServicePortOperaton)
updateServiceCombo();
} catch (MalformedURLException e) {
return StatusUtils.errorStatus(JBossWSUIMessages.WSDLBrowseDialog_Status_Invalid_URL, e);
- } catch (WSDLException e) {
- return StatusUtils.errorStatus(JBossWSUIMessages.WSDLBrowseDialog_Status_WSDL_Unavailable, e);
+// } catch (WSDLException e) {
+// return StatusUtils.errorStatus(JBossWSUIMessages.WSDLBrowseDialog_Status_WSDL_Unavailable, e);
}
return Status.OK_STATUS;
}
@@ -509,7 +614,7 @@
if (WSDLBrowseDialog.wsdlTextValue != null) {
this.locationCombo.setText(wsdlTextValue);
- IStatus status = validate();
+ IStatus status = validate(false);
if (status != Status.OK_STATUS) {
if (showServicePortOperaton)
setGroupEnabled(false);
More information about the jbosstools-commits
mailing list