[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Thu May 31 13:42:51 UTC 2007


senger
Thu May 31 09:42:51 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory dev.open-bio.org:/tmp/cvs-serv1857/src/main/org/biomoby/client

Modified Files:
	AsyncClient.java CentralImpl.java 
Log Message:
starting addign support for async services
moby-live/Java/src/main/org/biomoby/client AsyncClient.java,1.1,1.2 CentralImpl.java,1.48,1.49
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/AsyncClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/AsyncClient.java	2007/03/30 21:17:27	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/AsyncClient.java	2007/05/31 13:42:51	1.2
@@ -35,7 +35,6 @@
     public static final String WSRP_PROPERTY_TAG_NAME = "ResourceProperty";
 
     public static final String MOBY_SERVICE_INVOC_ID_TAG_NAME = "ServiceInvocationId";
-    public static final String MOBY_SUBMIT_ACTION_CMD_SUFFIX = "_submit";
     public static final String MOBY_RESULT_PROPERTY_PREFIX = "result_";
 
     public static EndpointReference sendRequest(MobyService service, MobyContentInstance contents) throws Exception{
@@ -72,7 +71,7 @@
 	// Populate the body
 	// Create the main element and namespace
 	SOAPElement bodyElement = body.addChildElement(envelope.createName(
-									   servicename + MOBY_SUBMIT_ACTION_CMD_SUFFIX, 
+									   servicename + MobyService.SUBMIT_ACTION_SUFFIX, 
 									   MobyPrefixResolver.MOBY_TRANSPORT_PREFIX, 
 									   MobyPrefixResolver.MOBY_TRANSPORT_NAMESPACE));
 	// Add content
@@ -97,7 +96,7 @@
 	httpConn.setRequestProperty("Content-Type", CONTENT_TYPE);
 	httpConn.setRequestProperty("User-agent", USER_AGENT);
 	httpConn.setRequestProperty("SOAPAction", MobyPrefixResolver.MOBY_TRANSPORT_NAMESPACE+"#"
-				    + servicename + MOBY_SUBMIT_ACTION_CMD_SUFFIX);
+				    + servicename + MobyService.SUBMIT_ACTION_SUFFIX);
 	httpConn.setRequestMethod("POST");
 	httpConn.setDoOutput(true);
 	httpConn.setDoInput(true);

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2007/05/29 03:51:46	1.48
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2007/05/31 13:42:51	1.49
@@ -24,6 +24,7 @@
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.DocumentBuilder;
+import javax.xml.namespace.QName;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
@@ -35,6 +36,7 @@
 import org.apache.axis.client.Service;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -219,7 +221,12 @@
 
 	} catch (AxisFault e) {
 	    throw new MobyException
-		(endpoint.toString()+(call == null ? "" : call.getOperationName()), e);
+		(formatFault (e,
+			      endpoint.toString(),
+			      (call == null ? null : call.getOperationName())),
+		 e);
+// 		(endpoint.toString()+(call == null ? "" : call.getOperationName()), e);
+
 	} catch (Exception e) {
 	    throw new MobyException (e.toString(), e);
 // 	    e.printStackTrace();
@@ -1873,5 +1880,46 @@
         return (buffer == null) ? str : buffer.toString();
     }
 
+    /*************************************************************************
+     * Format an exception.
+     *************************************************************************/
+    public static String formatFault (AxisFault e, String endpoint, QName method) {
+	ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	formatFault (e, new PrintStream (baos), endpoint, method);
+	return baos.toString();
+    }
+
+    /*************************************************************************
+     * Format an exception.
+     *************************************************************************/
+    public static void formatFault (AxisFault e, PrintStream out,
+				    String endpoint, QName method) {
+	    
+	out.println ("===ERROR===");
+	out.println ("Fault details:");
+	// for some obvious errors I do not print all details (with a lenghty trace stack)
+	String faultString = e.getFaultString();
+	if ( (! faultString.startsWith ("java.net.ConnectException")) &&
+	     (faultString.indexOf ("Could not find class for the service named:") == -1)
+	     ) {
+	    org.w3c.dom.Element[] details = e.getFaultDetails();
+	    for (int i = 0; i < details.length; i++) {
+		String s = details[i].toString().replaceAll ("&lt;", "<");
+		s = s.replaceAll ("&gt;", ">");
+		out.println (s);
+	    }
+	}
+	out.println ("Fault string: " + faultString);
+	out.println ("Fault code:   " + e.getFaultCode());
+	out.println ("Fault actor:  " + e.getFaultActor());
+	if (endpoint != null || method != null)
+	    out.println ("When calling:");
+	if (endpoint != null)
+	    out.println ("\t" + endpoint);
+	if (method != null)
+	    out.println ("\t" + method);
+	out.println ("===========");
+    }
+
 
 }




More information about the MOBY-guts mailing list