[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Oct 30 02:33:25 UTC 2008


gordonp
Wed Oct 29 22:33:25 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service
In directory dev.open-bio.org:/tmp/cvs-serv10500/src/main/org/biomoby/service

Modified Files:
	MobyServlet.java 
Log Message:
Updates related to SAWSDL wrapping Web Service implementation
moby-live/Java/src/main/org/biomoby/service MobyServlet.java,1.15,1.16
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2008/03/13 23:02:22	1.15
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2008/10/30 02:33:25	1.16
@@ -165,11 +165,6 @@
 			  HttpServletResponse response)
 	throws ServletException, java.io.IOException{
 
-	// Check that the right method call was made
-	if(!validSOAPEndPoint(request, response)){
-	    return;
-	}
-
 	if(thisService == null){
 	    try{
 		thisService = createServiceFromConfig(request);
@@ -178,6 +173,13 @@
 	    }
 	}
 
+	// Check that the right method call was made
+	// Run this after the config, because a subclass might not know the 
+	// proper SOAP endpoint name until the first call has been made
+	if(!validSOAPEndPoint(request, response)){
+	    return;
+	}
+
 	MobyContentInstance mobyResultContents = new MobyContentInstance();
 	try{
 	    MobyContentInstance mobyRequestContents = getMobyContents(request);
@@ -470,6 +472,9 @@
 			}
 			if(!isInList){
 			    // Illegal value given, use the default instead
+			    (new IllegalArgumentException("Illegal value '"+ val + "' for secondary param '" +
+							 param.getName() + "' being replaced with default value '" +
+							 param.getDefaultValue() + "'")).printStackTrace();
 			    matchingValue.setValue(param.getDefaultValue());
 			}
 		    }
@@ -564,6 +569,22 @@
 	response.setContentType("text/xml");
 
 	try{
+	    if(bodyContentsName == null){ //first call
+		SOAPFactory soapFactory = SOAPFactory.newInstance();
+		bodyContentsName = soapFactory.createName(getServiceName()+"Return",
+							  MobyPrefixResolver.MOBY_TRANSPORT_PREFIX,
+							  MobyPrefixResolver.MOBY_TRANSPORT_NAMESPACE);
+		bodyName = soapFactory.createName(getServiceName()+"Response",
+						  MobyPrefixResolver.MOBY_TRANSPORT_PREFIX, 
+						  MobyPrefixResolver.MOBY_TRANSPORT_NAMESPACE);
+		stringEncAttrName = soapFactory.createName("type",
+							   MobyPrefixResolver.XSI2001_PREFIX,
+							   MobyPrefixResolver.XSI_NAMESPACE2001);
+		faultName = soapFactory.createName("Client",
+						   "", 
+						   SOAPConstants.URI_NS_SOAP_ENVELOPE);
+	    }
+
 	    java.io.ByteArrayOutputStream bytesOut = new java.io.ByteArrayOutputStream(INIT_OUTPUT_BUFFER_SIZE);
 	    MobyDataUtils.toXMLDocument(bytesOut, mobyResults);
 
@@ -676,24 +697,16 @@
 				   "org.apache.xalan.processor.TransformerFactoryImpl");
 	    }
 
-	    //if(System.getProperty("javax.xml.soap.MessageFactory") == null){
-	//	System.setProperty("javax.xml.soap.MessageFactory", 
-	//			   "org.apache.axis.soap.MessageFactoryImpl");
-	 //   }
-	    soapMessageFactory = MessageFactory.newInstance();  // Should find Axis by default
-	    SOAPFactory soapFactory = SOAPFactory.newInstance();
-	    bodyContentsName = soapFactory.createName(getServiceName()+"Return",
-						      MobyPrefixResolver.MOBY_TRANSPORT_PREFIX,
-						      MobyPrefixResolver.MOBY_TRANSPORT_NAMESPACE);
-	    bodyName = soapFactory.createName(getServiceName()+"Response",
-					      MobyPrefixResolver.MOBY_TRANSPORT_PREFIX, 
-					      MobyPrefixResolver.MOBY_TRANSPORT_NAMESPACE);
-	    stringEncAttrName = soapFactory.createName("type",
-						       MobyPrefixResolver.XSI2001_PREFIX,
-						       MobyPrefixResolver.XSI_NAMESPACE2001);
-	    faultName = soapFactory.createName("Client",
-					       "", 
-					       SOAPConstants.URI_NS_SOAP_ENVELOPE);
+	    // This is a better implementation than Axis, so force it (avoids servlet container issues too)
+	    if(System.getProperty("javax.xml.soap.MessageFactory") == null){
+		System.setProperty("javax.xml.soap.MessageFactory", 
+				   "org.apache.axis.soap.MessageFactoryImpl");
+	    }
+	    if(System.getProperty("javax.xml.soap.SOAPFactory") == null){
+		System.setProperty("javax.xml.soap.SOAPFactory", 
+				   "org.apache.axis.soap.SOAPFactoryImpl");
+	    }
+	    soapMessageFactory = MessageFactory.newInstance();
 
 	    // Maps storing invocation-specific context variable
 	    templatedServicesMap = new HashMap<Thread,MobyService>();
@@ -836,7 +849,9 @@
 	}
 	if(secondaries != null && secondaries.length > 0){
 	    for(String secondary: secondaries){
-		inputTypes.add(stringToSecondaryDataTemplate(secondary));
+		if(secondary != null && secondary.length() > 0){
+		    inputTypes.add(stringToSecondaryDataTemplate(secondary));
+		}
 	    }
 	}
 
@@ -966,6 +981,11 @@
 	mobyService ann = 
 	    this.getClass().getAnnotation(mobyService.class);
 
+	// The best way to get the name is via the configured service, if it exists
+	if(thisService != null && thisService.getName() != null && thisService.getName().trim().length() > 0){
+	    return thisService.getName();
+	}
+
 	String param = null;
 	// Did we override the service type in the web.xml?
 	if(getCoCInitParameter(MOBY_SERVICENAME_PARAM) != null){
@@ -1373,7 +1393,7 @@
 	// Configure the service, minimally, to check the input data
 	java.net.URL webXMLURL = classLoader.getResource("WEB-INF/web.xml");
 	if(webXMLURL == null){
-	    System.err.println("No WEB-INF/web.xml, assuming you don't need any of its settings for the servlet to work!");
+	    System.err.println("No WEB-INF/web.xml was found, assuming you don't need any of its settings for the servlet to work!");
 	    servlet.init(new TestServletConfig(args[0], new TestServletContext()));
 	}
 	else{




More information about the MOBY-guts mailing list