Author: bfitzpat
Date: 2010-05-21 10:59:14 -0400 (Fri, 21 May 2010)
New Revision: 22246
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java
Log:
JBIDE-6281 - putting in better JAX-WS fault handling and JAX-RS parameter handling in URL
("?")
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java 2010-05-21
14:09:56 UTC (rev 22245)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java 2010-05-21
14:59:14 UTC (rev 22246)
@@ -157,8 +157,21 @@
URL url = null;
if (query != null) {
// add the ? if there are parameters
- if (!address.endsWith("?") &&
methodType.equalsIgnoreCase("GET") ) { //$NON-NLS-1$//$NON-NLS-2$
- address = address + "?"; //$NON-NLS-1$
+ if (!address.endsWith("?")) {//$NON-NLS-1$
+
+ // if we're a "GET" - add the ? by default
+ if (methodType.equalsIgnoreCase("GET")) { //$NON-NLS-1$
+ address = address + "?"; //$NON-NLS-1$
+
+ // if we're a PUT or POST, check if we have parms
+ // and add the ? if we do
+ } else if (methodType.equalsIgnoreCase("POST")//$NON-NLS-1$
+ || methodType.equalsIgnoreCase("PUT") //$NON-NLS-1$
+ || methodType.equalsIgnoreCase("DELETE")) { //$NON-NLS-1$
+ if (query.trim().length() > 0) {
+ address = address + "?"; //$NON-NLS-1$
+ }
+ }
}
// add parms to the url if we have some
url = new URL(address + query);
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester.java 2010-05-21
14:09:56 UTC (rev 22245)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester.java 2010-05-21
14:59:14 UTC (rev 22246)
@@ -17,6 +17,7 @@
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
+import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.client.Call;
@@ -89,26 +90,61 @@
call.setProperty(Call.SOAPACTION_URI_PROPERTY,action);
}
Message message = new Message(document);
- SOAPEnvelope envelope = call.invoke( message );
- // Get back the response message
+ SOAPEnvelope envelope = null;
+
this.resultBody = EMPTY_STRING;
- if (envelope != null && envelope.getBody() != null) {
- this.resultBody = envelope.getBody().toString();
- }
-
- // Get back the response HTTP headers and pass back as a Map
- if (call != null && call.getMessageContext() != null) {
- MessageContext mc = call.getMessageContext();
- if (mc.getMessage() != null && mc.getMessage().getMimeHeaders() != null) {
- MimeHeaders mh = mc.getMessage().getMimeHeaders();
- Iterator<?> iter = mh.getAllHeaders();
+
+ try {
+ envelope = call.invoke( message );
+
+ // Get back the response message
+ if (envelope != null && envelope.getBody() != null) {
+ this.resultBody = envelope.getBody().toString();
+ }
+
+ // Get back the response HTTP headers and pass back as a Map
+ if (call != null && call.getMessageContext() != null) {
+ MessageContext mc = call.getMessageContext();
+ if (mc.getMessage() != null && mc.getMessage().getMimeHeaders() != null) {
+ MimeHeaders mh = mc.getMessage().getMimeHeaders();
+ Iterator<?> iter = mh.getAllHeaders();
+ resultHeaders = new HashMap<String, String>();
+ while (iter.hasNext()) {
+ MimeHeader next = (MimeHeader)iter.next();
+ resultHeaders.put(next.getName(), next.getValue());
+ }
+ }
+ }
+ } catch (AxisFault fault){
+
+ // Get back the response message
+ if (fault.getFaultString() != null) {
+ this.resultBody = fault.getFaultString();
+ }
+
+ // Get back the response HTTP headers and pass back as a Map
+ if (fault.getHeaders() != null && !fault.getHeaders().isEmpty()) {
+ Iterator<?> iter = fault.getHeaders().iterator();
resultHeaders = new HashMap<String, String>();
while (iter.hasNext()) {
- MimeHeader next = (MimeHeader)iter.next();
- resultHeaders.put(next.getName(), next.getValue());
+ Object next = iter.next();
+ resultHeaders.put(next.toString(), ""); //$NON-NLS-1$
}
+ } else if (call != null && call.getMessageContext() != null) {
+ MessageContext mc = call.getMessageContext();
+ if (mc.getMessage() != null && mc.getMessage().getMimeHeaders() != null) {
+ MimeHeaders mh = mc.getMessage().getMimeHeaders();
+ Iterator<?> iter = mh.getAllHeaders();
+ resultHeaders = new HashMap<String, String>();
+ while (iter.hasNext()) {
+ MimeHeader next = (MimeHeader)iter.next();
+ resultHeaders.put(next.getName(), next.getValue());
+ }
+ }
}
+
}
+
}
}
\ No newline at end of file
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java 2010-05-21
14:09:56 UTC (rev 22245)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView.java 2010-05-21
14:59:14 UTC (rev 22246)
@@ -425,7 +425,7 @@
parmsList.setEnabled(false);
dlsList.setEnabled(false);
parmsTab.getControl().setEnabled(false);
- headerTab.getControl().setEnabled(false);
+ headerTab.getControl().setEnabled(true);
methodCombo.setText(POST);
String emptySOAP = "<?xml version=\"1.0\"
standalone=\"yes\" ?>" + //$NON-NLS-1$