You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@locus.apache.org on 2000/11/08 13:58:31 UTC
cvs commit: xml-soap/java/src/org/apache/soap/util StringUtils.java
dug 00/11/08 04:58:30
Modified: java build.xml
java/src/org/apache/soap/rpc RPCMessage.java
java/src/org/apache/soap/server DeploymentDescriptor.java
RPCRouter.java
java/src/org/apache/soap/server/http ServerHTTPUtils.java
java/src/org/apache/soap/util StringUtils.java
Added: java/samples/provider DeploymentDescriptor.xml README
testit.cmd testit.sh testprovider.java
Log:
- Missing pluggable provider 'option' tags in toXML
- Only build EJB Provider if javax.ejb.SessionBean is present
- Added a sample to test the TemplateProvider
- Remove client's dependency on javax that was introduced
Revision Changes Path
1.15 +3 -1 xml-soap/java/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-soap/java/build.xml,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- build.xml 2000/08/18 17:21:28 1.14
+++ build.xml 2000/11/08 12:58:16 1.15
@@ -39,7 +39,7 @@
Copyright:
Copyright (c) 2000 Apache Software Foundation.
- $Id: build.xml,v 1.14 2000/08/18 17:21:28 duftler Exp $
+ $Id: build.xml,v 1.15 2000/11/08 12:58:16 dug Exp $
==================================================================== -->
@@ -84,6 +84,7 @@
classname="com.ibm.network.mail.pop3.event.StatusListener" />
<available property="smtp.present"
classname="com.ibm.network.mail.smtp.protocol.CoreProtocolBean" />
+ <available property="ejb.present" classname="javax.ejb.SessionBean" />
</target>
<!-- =================================================================== -->
@@ -98,6 +99,7 @@
<exclude name="**/POP*.java" unless="smtp.present" />
<exclude name="**/POP*.java" unless="pop3.present" />
<exclude name="**/XMI*.java" unless="xmi.present" />
+ <exclude name="**/*EJB*.java" unless="ejb.present" />
</javac>
<mkdir dir="${build.lib}"/>
<jar jarfile="${build.lib}/${name}.jar" basedir="${build.dest}" />
1.1 xml-soap/java/samples/provider/DeploymentDescriptor.xml
Index: DeploymentDescriptor.xml
===================================================================
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
id="urn:testprovider">
<isd:provider type="org.apache.soap.providers.TemplateProvider"
scope="Application"
methods="dummyMethod">
<isd:java class="samples.provider.provider"/>
<isd:option key="classpath" value="c:\classes" />
</isd:provider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
</isd:service>
1.1 xml-soap/java/samples/provider/README
Index: README
===================================================================
Service:
-------
To install this service on an Apache-SOAP listener, you need to deploy this
service by filling in the deployment template using the info in the deployment
descriptor in this directory or by using the service manager client at:
http://host:port/soap-servlet/admin (ie. http://localhost:8080/soap/admin)
To deploy using the deployment descriptor in this directory use the java
program:
java org.apache.soap.server.ServiceManagerClient routerURL deploy dd.xml
where routerURL is the URL of the SOAP RPC router and dd.xml is the name of
the deployment descriptor file. For example:
java org.apache.soap.server.ServiceManagerClient \
http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml
Client:
------
There is a client that uses HTTP as the transport. Run the following
command to see some output from the TemplateProvider on the server machine:
java samples.provider.testprovider routerURL
For example:
java samples.provider.testprovider http://localhost:8080/soap/servlet/rpcrouter
Explanation:
-----------
Prints some debug information on the SOAP server to show it worked.
Should look something like:
=============================================
In TemplateProvider.locate()
URI: urn:testprovider
DD.ServiceClass: org.apache.soap.providers.TemplateProvider
DD.ProviderClass: samples.provider.provider
Call.MethodName: hello
Options:
Key: classpath Value: c:\classes
=============================================
In TemplateProvider.invoke()
1.1 xml-soap/java/samples/provider/testit.cmd
Index: testit.cmd
===================================================================
@echo off
echo This test assumes a server URL of http://localhost:8080/soap/server/rpcrouter
echo Deploying the testprovider service...
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml
echo .
echo Verify that its there
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list
echo .
echo Running the testprovider client
java samples.provider.testprovider http://localhost:8080/soap/servlet/rpcrouter
echo .
echo Undeploy it now
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter undeploy urn:testprovider
echo .
echo Verify that its gone
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list
1.1 xml-soap/java/samples/provider/testit.sh
Index: testit.sh
===================================================================
echo This test assumes a server URL of http://localhost:8080/soap/server/rpcrouter
echo Deploying the testprovider service...
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml
echo
echo Verify that its there
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list
echo
echo Running the testprovider client
java samples.provider.testprovider http://localhost:8080/soap/servlet/rpcrouter
echo
echo Undeploy it now
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter undeploy urn:testprovider
echo
echo Verify that its gone
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list
1.1 xml-soap/java/samples/provider/testprovider.java
Index: testprovider.java
===================================================================
package samples.provider;
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
public class testprovider {
static XMLParserLiaison xpl = new XercesParserLiaison ();
public static void main (String[] args) throws Exception {
if (args.length != 1 ) {
System.err.println ("Usage: java " + testprovider.class.getName () +
" SOAP-router-URL");
System.exit (1);
}
// Process the arguments.
URL url = new URL (args[0]);
// Build the call.
Call call = new Call ();
call.setTargetObjectURI ("urn:testprovider");
call.setMethodName ("hello");
Vector params = new Vector ();
// params.addElement (new Parameter("symbol", String.class, symbol, null));
call.setParams (params);
// make the call: note that the action URI is empty because the
// XML-SOAP rpc router does not need this. This may change in the
// future.
Response resp = call.invoke (/* router URL */ url, /* actionURI */ "" );
// Check the response.
if (resp.generatedFault ()) {
Fault fault = resp.getFault ();
System.out.println ("Ouch, the call failed: ");
System.out.println (" Fault Code = " + fault.getFaultCode ());
System.out.println (" Fault String = " + fault.getFaultString ());
} else {
Parameter result = resp.getReturnValue ();
System.out.println ( "Done" );
}
}
}
1.6 +2 -3 xml-soap/java/src/org/apache/soap/rpc/RPCMessage.java
Index: RPCMessage.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/RPCMessage.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RPCMessage.java 2000/11/07 00:34:59 1.5
+++ RPCMessage.java 2000/11/08 12:58:20 1.6
@@ -65,7 +65,6 @@
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.server.*;
-import org.apache.soap.server.http.ServerHTTPUtils;
/**
* An <code>RPCMessage</code> is the base class that <code>Call</code> and
@@ -101,7 +100,7 @@
// Now, we should splice the URI into the actual resource to connect to,
// and the key.
- this.targetObjectURI = ServerHTTPUtils.parseFullTargetObjectURI(targetObjectURI);
+ this.targetObjectURI = StringUtils.parseFullTargetObjectURI(targetObjectURI);
}
public String getTargetObjectURI()
@@ -384,7 +383,7 @@
// This is the 'full' URI.
fullTargetObjectURI = root.getNamespaceURI();
- targetObjectURI = ServerHTTPUtils.parseFullTargetObjectURI(fullTargetObjectURI);
+ targetObjectURI = StringUtils.parseFullTargetObjectURI(fullTargetObjectURI);
// Determine the XML serialization registry based on whether
// I'm on the server side or on the client side.
1.12 +8 -0 xml-soap/java/src/org/apache/soap/server/DeploymentDescriptor.java
Index: DeploymentDescriptor.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/DeploymentDescriptor.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DeploymentDescriptor.java 2000/11/07 00:34:59 1.11
+++ DeploymentDescriptor.java 2000/11/08 12:58:22 1.12
@@ -342,6 +342,14 @@
pw.println (" <isd:" + serviceClass + " class=\"" + providerClass +
"\" static=\"" + (isStatic ? "true" : "false") + "\"/>");
}
+
+ for ( Enumeration e = props.keys() ; e.hasMoreElements(); ) {
+ String key = (String) e.nextElement() ;
+ String value = (String) props.get(key);
+ pw.println(" <isd:option key=\"" + key + "\" value=\"" +
+ value + "\" />" );
+ }
+
pw.println (" </isd:provider>");
if (faultListener != null) {
1.5 +2 -1 xml-soap/java/src/org/apache/soap/server/RPCRouter.java
Index: RPCRouter.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/RPCRouter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- RPCRouter.java 2000/11/07 00:34:59 1.4
+++ RPCRouter.java 2000/11/08 12:58:22 1.5
@@ -9,6 +9,7 @@
import org.apache.soap.util.IOUtils;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
+import org.apache.soap.util.StringUtils;
import org.apache.soap.server.http.ServerHTTPUtils;
@@ -27,7 +28,7 @@
// determine target object URI by looking in the envelope
Vector bodyEntries = callEnv.getBody ().getBodyEntries ();
Element mainEntry = (Element) bodyEntries.elementAt (0);
- String targetObjectURI = ServerHTTPUtils.parseFullTargetObjectURI(mainEntry.getNamespaceURI ());
+ String targetObjectURI = StringUtils.parseFullTargetObjectURI(mainEntry.getNamespaceURI ());
// call on known entity?
DeploymentDescriptor dd = serviceManager.query (targetObjectURI);
1.7 +9 -25 xml-soap/java/src/org/apache/soap/server/http/ServerHTTPUtils.java
Index: ServerHTTPUtils.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/ServerHTTPUtils.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServerHTTPUtils.java 2000/11/07 02:05:15 1.6
+++ ServerHTTPUtils.java 2000/11/08 12:58:24 1.7
@@ -78,7 +78,6 @@
private static final String SCRIPT_CLASS = "com.ibm.bsf.BSFManager";
private static final String SCRIPT_INVOKER =
"org.apache.soap.server.InvokeBSF";
- private static String URI_SEPARATION_CHAR = "@";
/**
* Look up the service manager or create it from the context. NOTE:
@@ -331,25 +330,6 @@
return targetObject;
}
- /**
- * gegi: This method will perform the splicing of a full URI. It is currently
- * the only place where the delimiting character in the URI that triggers the
- * splicing operation is specified. (This character should later be specified
- * as a constant...
- *
- * Creation date: (10/23/00 2:54:33 PM)
- * @return java.lang.String
- * @param fullTargetObjectURI java.lang.String
- */
- public static String parseFullTargetObjectURI(String fullTargetObjectURI) {
- if ( fullTargetObjectURI == null ) return null ;
- int delimIndex = fullTargetObjectURI.indexOf(ServerHTTPUtils.URI_SEPARATION_CHAR);
- if ( (fullTargetObjectURI != null) && (delimIndex != -1) )
- return fullTargetObjectURI.substring(0,delimIndex);
- else
- return fullTargetObjectURI;
-
- }
public static Provider loadProvider(DeploymentDescriptor dd)
throws SOAPException {
@@ -359,7 +339,12 @@
className = dd.getServiceClass();
if ( className == null ) return null ;
-
+
+ if ( "java" == className )
+ className = "org.apache.soap.providers.JavaProvider" ;
+ else if ( "script" == className )
+ className = "org.apache.soap.providers.JavaProvider" ;
+
try {
c = Class.forName (className);
newObj = c.newInstance();
@@ -368,10 +353,9 @@
"Can't load provider '" + className + "'", exp);
}
- if ( !(newObj instanceof Provider) ) {
- System.err.println("NOT PROVIDER");
- return null ;
- }
+ if ( !(newObj instanceof Provider) )
+ throw new SOAPException( Constants.FAULT_CODE_SERVER,
+ "'" + className + "' isn't a provider");
return (Provider) newObj ;
}
1.4 +25 -2 xml-soap/java/src/org/apache/soap/util/StringUtils.java
Index: StringUtils.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/StringUtils.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StringUtils.java 2000/09/01 03:53:03 1.3
+++ StringUtils.java 2000/11/08 12:58:28 1.4
@@ -55,7 +55,7 @@
* <http://www.apache.org/>.
*/
-/* $Id: StringUtils.java,v 1.3 2000/09/01 03:53:03 sanjiva Exp $ */
+/* $Id: StringUtils.java,v 1.4 2000/11/08 12:58:28 dug Exp $ */
package org.apache.soap.util;
@@ -68,7 +68,7 @@
/**
* Deals with strings (probably need to elaborate some more).
*
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
* @author Matthew J. Duftler
*/
public class StringUtils
@@ -76,6 +76,7 @@
public static final String lineSeparator =
System.getProperty("line.separator", "\n");
public static final String lineSeparatorStr = cleanString(lineSeparator);
+ public static String URI_SEPARATION_CHAR = "@";
// Handles multi-line strings.
public static String getSafeString(String scriptStr)
@@ -458,4 +459,26 @@
{
return IOUtils.getStringFromReader(getContentAsReader(url));
}
+
+ /**
+ * This method will perform the splicing of a full URI. It is currently
+ * the only place where the delimiting character in the URI that triggers the
+ * splicing operation is specified. (This character should later be specified
+ * as a constant...
+ *
+ * Creation date: (10/23/00 2:54:33 PM)
+ * @return java.lang.String
+ * @param fullTargetObjectURI java.lang.String
+ */
+ public static String parseFullTargetObjectURI(String fullTargetObjectURI) {
+ if ( fullTargetObjectURI == null ) return null ;
+ int delimIndex = fullTargetObjectURI.indexOf(URI_SEPARATION_CHAR);
+ if ( (fullTargetObjectURI != null) && (delimIndex != -1) )
+ return fullTargetObjectURI.substring(0,delimIndex);
+ else
+ return fullTargetObjectURI;
+
+ }
+
+
}