You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by du...@apache.org on 2001/10/15 21:24:01 UTC
cvs commit: xml-axis/java/src/org/apache/axis/message SOAPBodyElement.java
dug 01/10/15 12:24:01
Modified: java build.xml
java/samples/stock GetQuote.java GetQuote1.java testit.cmd
testit.sh
java/samples/transport FileTest.java
java/src/org/apache/axis Constants.java
java/src/org/apache/axis/client AdminClient.java Call.java
Service.java
java/src/org/apache/axis/message SOAPBodyElement.java
Log:
- Start adding support for messaging using new Call interface.
See AdminClient for an example - I'll be switching over the samples soon.
- Added an "all" target in build.xml to do "dist" and "functional-tests".
- Remove some Axis extensions in Call.java in favor of using properties
instead.
- Moved some Call constants from Constants.java to Call.java
Revision Changes Path
1.52 +5 -0 xml-axis/java/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/build.xml,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- build.xml 2001/10/12 16:37:33 1.51
+++ build.xml 2001/10/15 19:24:00 1.52
@@ -343,6 +343,11 @@
</target>
<!-- =================================================================== -->
+ <!-- Build/Test EVERYTHING from scratch! -->
+ <!-- =================================================================== -->
+ <target name="all" depends="dist, functional-tests"/>
+
+ <!-- =================================================================== -->
<!-- Creates the binary distribution -->
<!-- =================================================================== -->
<target name="dist" depends="compile, junit, samples, javadocs" >
1.29 +3 -3 xml-axis/java/samples/stock/GetQuote.java
Index: GetQuote.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/GetQuote.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- GetQuote.java 2001/10/11 19:00:56 1.28
+++ GetQuote.java 2001/10/15 19:24:00 1.29
@@ -64,7 +64,7 @@
import org.apache.axis.client.Service ;
import org.apache.axis.client.Transport ;
import org.apache.axis.transport.http.HTTPConstants;
-import org.apache.axis.rpc.Call ;
+import org.apache.axis.client.Call ;
import org.apache.axis.encoding.XMLType ;
import org.apache.axis.utils.Options ;
@@ -90,11 +90,11 @@
symbol = args[0] ;
Service service = new Service();
- Call call = service.createCall();
+ Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new URL(opts.getURL()) );
call.setOperationName( "getQuote" );
- call.setProperty( Constants.NAMESPACE, "urn:xmltoday-delayed-quotes" );
+ call.setProperty( Call.NAMESPACE, "urn:xmltoday-delayed-quotes" );
call.addParameter( "symbol", XMLType.XSD_STRING, Call.PARAM_MODE_IN );
call.setReturnType( XMLType.XSD_FLOAT );
1.9 +4 -4 xml-axis/java/samples/stock/GetQuote1.java
Index: GetQuote1.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/GetQuote1.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- GetQuote1.java 2001/10/07 02:07:19 1.8
+++ GetQuote1.java 2001/10/15 19:24:00 1.9
@@ -63,7 +63,7 @@
import org.apache.axis.client.Service ;
import org.apache.axis.client.Transport ;
import org.apache.axis.encoding.XMLType ;
-import org.apache.axis.rpc.Call ;
+import org.apache.axis.client.Call ;
import org.apache.axis.rpc.namespace.QName ;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.axis.utils.Options ;
@@ -105,7 +105,7 @@
/* Now use those QNames as pointers into the WSDL doc */
/******************************************************/
Service service = new Service( new URL("file:GetQuote.wsdl"), servQN );
- Call call = service.createCall( portQN, "getQuote" );
+ Call call = (Call) service.createCall( portQN, "getQuote" );
/* Strange - but allows the user to change just certain portions of */
/* the URL we're gonna use to invoke the service. Useful when you */
@@ -142,7 +142,7 @@
/* Create default/empty Service and Call object */
/************************************************/
Service service = new Service();
- Call call = service.createCall();
+ Call call = (Call) service.createCall();
/* Strange - but allows the user to change just certain portions of */
/* the URL we're gonna use to invoke the service. Useful when you */
@@ -154,7 +154,7 @@
/***********************************************************/
call.setTargetEndpointAddress( new URL(opts.getURL()) );
call.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, "getQuote" );
- call.setProperty( Constants.NAMESPACE, "urn:xmltoday-delayed-quotes" );
+ call.setProperty( Call.NAMESPACE, "urn:xmltoday-delayed-quotes" );
call.setEncodingStyle( "http://schemas.xmlsoap.org/soap/encoding/" );
call.setOperationName( "getQuote" );
call.addParameter( "symbol", XMLType.XSD_STRING, Call.PARAM_MODE_IN );
1.10 +9 -9 xml-axis/java/samples/stock/testit.cmd
Index: testit.cmd
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/testit.cmd,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- testit.cmd 2001/08/11 14:43:46 1.9
+++ testit.cmd 2001/10/15 19:24:00 1.10
@@ -1,22 +1,22 @@
rem this assumes webserver is running on port 8080
echo First test the StockQuoteService.jws file
-java samples.stock.GetQuote -uuser1 -wpass1 XXX -s/axis/StockQuoteService.jws
+java samples.stock.GetQuote -uuser1 -wpass1 XXX -s/axis/StockQuoteService.jws %*
echo Deploy everything first
-java org.apache.axis.client.AdminClient deploy.xml
+java org.apache.axis.client.AdminClient deploy.xml %*
echo These next 2 should work...
-java samples.stock.GetQuote -uuser1 -wpass1 XXX
-java samples.stock.GetQuote -uuser2 XXX
+java samples.stock.GetQuote -uuser1 -wpass1 XXX %*
+java samples.stock.GetQuote -uuser2 XXX %*
echo The rest of these should fail... (nicely of course)
-java samples.stock.GetQuote XXX
-java samples.stock.GetQuote -uuser1 -wpass2 XXX
-java samples.stock.GetQuote -uuser3 -wpass3 XXX
+java samples.stock.GetQuote XXX %*
+java samples.stock.GetQuote -uuser1 -wpass2 XXX %*
+java samples.stock.GetQuote -uuser3 -wpass3 XXX %*
echo This should work but print debug info on the client and server
-java samples.stock.GetQuote -d -uuser1 -wpass1 XXX
+java samples.stock.GetQuote -d -uuser1 -wpass1 XXX %*
echo Now undeploy everything
-java org.apache.axis.client.AdminClient undeploy.xml
+java org.apache.axis.client.AdminClient undeploy.xml %*
1.9 +8 -8 xml-axis/java/samples/stock/testit.sh
Index: testit.sh
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/testit.sh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- testit.sh 2001/08/11 14:43:46 1.8
+++ testit.sh 2001/10/15 19:24:00 1.9
@@ -2,19 +2,19 @@
# this assumes webserver is running on port 8080
echo "Deploy everything first"
-java org.apache.axis.client.AdminClient deploy.xml
+java org.apache.axis.client.AdminClient deploy.xml $*
echo "These next 2 should work..."
-java samples.stock.GetQuote -uuser1 -wpass1 XXX
-java samples.stock.GetQuote -uuser2 XXX
+java samples.stock.GetQuote -uuser1 -wpass1 XXX $*
+java samples.stock.GetQuote -uuser2 XXX $*
echo "The rest of these should fail... (nicely of course)"
-java samples.stock.GetQuote XXX
-java samples.stock.GetQuote -uuser1 -wpass2 XXX
-java samples.stock.GetQuote -uuser3 -wpass3 XXX
+java samples.stock.GetQuote XXX $*
+java samples.stock.GetQuote -uuser1 -wpass2 XXX $*
+java samples.stock.GetQuote -uuser3 -wpass3 XXX $*
echo "This should work but print debug info on the client and server"
-java samples.stock.GetQuote -d -uuser1 -wpass1 XXX
+java samples.stock.GetQuote -d -uuser1 -wpass1 XXX $*
# Now undeploy everything
-java org.apache.axis.client.AdminClient undeploy.xml
+java org.apache.axis.client.AdminClient undeploy.xml $*
1.14 +2 -2 xml-axis/java/samples/transport/FileTest.java
Index: FileTest.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/FileTest.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- FileTest.java 2001/10/11 19:07:21 1.13
+++ FileTest.java 2001/10/15 19:24:00 1.14
@@ -39,12 +39,12 @@
Call call = (Call) service.createCall();
call.setOperationName( "getQuote" );
call.addParameter( "symbol", XMLType.XSD_STRING, Call.PARAM_MODE_IN );
- call.setProperty( Constants.NAMESPACE, "urn:xmltoday-delayed-quotes" );
+ call.setProperty( Call.NAMESPACE, "urn:xmltoday-delayed-quotes" );
call.setReturnType( XMLType.XSD_FLOAT );
call.setTransport( new FileTransport() );
call.setProperty(Transport.USER, opts.getUser() );
call.setProperty(Transport.PASSWORD, opts.getPassword() );
- call.setTimeout(10000);
+ call.setProperty(Call.TIMEOUT, "10000");
Float res = new Float(0.0F);
res = (Float) call.invoke( new Object[] {symbol} );
1.33 +0 -2 xml-axis/java/src/org/apache/axis/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Constants.java 2001/10/02 14:10:06 1.32
+++ Constants.java 2001/10/15 19:24:00 1.33
@@ -193,6 +193,4 @@
public static final String SERVER_CONFIG_FILE = "server-config.xml";
public static final String CLIENT_CONFIG_FILE = "client-config.xml";
-
- public static final String NAMESPACE = "namespace" ;
}
1.34 +18 -28 xml-axis/java/src/org/apache/axis/client/AdminClient.java
Index: AdminClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/AdminClient.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- AdminClient.java 2001/10/03 15:30:03 1.33
+++ AdminClient.java 2001/10/15 19:24:00 1.34
@@ -58,12 +58,12 @@
import org.apache.axis.AxisEngine;
import org.apache.axis.Message;
import org.apache.axis.encoding.SerializationContext;
-import org.apache.axis.encoding.ServiceDescription;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.axis.utils.Options;
+import java.util.Vector;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
@@ -71,6 +71,7 @@
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.net.URL;
/**
* An admin client object that can be used both from the command line
@@ -200,45 +201,34 @@
input = new FileInputStream( args[i] );
}
- ServiceClient client = new ServiceClient(opts.getURL());
-
- /** Unfortunately, this is transport-specific. However, no one
- * but the HTTP transport should pick this property up.
- */
- client.set(HTTPConstants.MC_HTTP_SOAPACTION, "AdminService");
-
- Message inMsg = new Message( input, true );
-
- client.setRequestMessage( inMsg );
-
- client.set( Transport.USER, opts.getUser() );
- client.set( Transport.PASSWORD, opts.getPassword() );
+ Service service = new Service();
+ Call call = (org.apache.axis.client.Call) service.createCall();
+ call.setTargetEndpointAddress( new URL(opts.getURL()) );
+ call.setProperty( HTTPConstants.MC_HTTP_SOAPACTION, "AdminService");
+ call.setProperty( Transport.USER, opts.getUser() );
+ call.setProperty( Transport.PASSWORD, opts.getPassword() );
+
String tName = opts.isValueSet( 't' );
if ( tName != null && !tName.equals("") )
- client.setTransportName( tName );
+ call.setProperty( Call.TRANSPORT_NAME, tName );
- client.invoke();
+ Vector result = null ;
+ Object[] params = new Object[] { new SOAPBodyElement(input) };
+ result = (Vector) call.invoke( params );
- Message outMsg = client.getMessageContext().
- getResponseMessage();
- if (outMsg == null) {
+ if (result == null || result.size() == 0) {
log("Null response message!");
return null;
}
- client
- .getMessageContext()
- .setServiceDescription(new ServiceDescription("Admin", false));
-
input.close();
- SOAPEnvelope envelope =
- (SOAPEnvelope) outMsg.getAsSOAPEnvelope();
- SOAPBodyElement body = envelope.getFirstBody();
+ SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0);
StringWriter writer = new StringWriter();
- client.addOption(AxisEngine.PROP_XML_DECL, new Boolean(false));
+ call.getEngine().addOption(AxisEngine.PROP_XML_DECL,
+ new Boolean(false));
SerializationContext ctx = new SerializationContext(writer,
- client.getMessageContext());
+ call.getMessageContext());
ctx.setPretty(true);
body.output(ctx);
sb.append(writer.toString());
1.10 +60 -39 xml-axis/java/src/org/apache/axis/client/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Call.java 2001/10/13 11:17:51 1.9
+++ Call.java 2001/10/15 19:24:00 1.10
@@ -110,7 +110,6 @@
// invoke() time
private Hashtable myProperties = null ;
- private int timeout = 0 ;
private boolean maintainSession = false ;
// Our Transport, if any
@@ -124,7 +123,10 @@
private Vector myHeaders = null;
- public static final String TRANSPORT_PROPERTY="java.protocol.handler.pkgs";
+ public static final String TRANSPORT_NAME = "transport_name" ;
+ public static final String TIMEOUT = "timeout" ;
+ public static final String NAMESPACE = "namespace" ;
+ public static final String TRANSPORT_PROPERTY= "java.protocol.handler.pkgs";
/**
* A Hashtable mapping protocols (Strings) to Transports (classes)
@@ -304,6 +306,13 @@
*/
public void setProperty(String name, Object value) {
if (name == null || value == null) return;
+
+ if ( name.equals(TRANSPORT_NAME) ) {
+ transportName = name ;
+ if ( transport != null )
+ transport.setTransportName( name );
+ return ;
+ }
if (myProperties == null)
myProperties = new Hashtable();
myProperties.put(name, value);
@@ -334,15 +343,51 @@
* Invokes the operation associated with this Call object using the
* passed in parameters as the arguments to the method.
*
+ * For Messaging (ie. non-RPC) the params argument should be an array
+ * of SOAPBodyElements. <b>All</b> of them need to be SOAPBodyElements,
+ * if any of them are not this method will default back to RPC. In the
+ * Messaging case the return value will be a vector of SOAPBodyElements.
+ *
* @param params Array of parameters to invoke the Web Service with
* @return Object Return value of the operation/method - or null
* @throws RemoteException if there's an error
*/
public Object invoke(Object[] params) throws java.rmi.RemoteException {
+ /* First see if we're dealing with Messaging instead of RPC. */
+ /* If ALL of the params are SOAPBodyElements then we're doing */
+ /* Messaging, otherwise just fall through to normal RPC processing. */
+ /********************************************************************/
+ int i ;
+ for ( i = 0 ; params != null && i < params.length ; i++ )
+ if ( !(params[i] instanceof SOAPBodyElement) ) break ;
+ if ( i == params.length ) {
+ /* ok, we're doing Messaging, so build up the message */
+ /******************************************************/
+ SOAPEnvelope env = new SOAPEnvelope();
+ Message msg = null ;
+
+ for ( i = 0 ; myHeaders != null && i < myHeaders.size() ; i++ )
+ env.addHeader((SOAPHeader)myHeaders.get(i));
+
+ for ( i = 0 ; i < params.length ; i++ )
+ env.addBodyElement( (SOAPBodyElement) params[i] );
+
+ msg = new Message( env );
+ msgContext.setRequestMessage( msg );
+
+ invoke();
+
+ msg = msgContext.getResponseMessage();
+ if ( msg == null ) return( null );
+ env = msg.getAsSOAPEnvelope();
+ return( env.getBodyElements() );
+ }
+
+
if ( operationName == null )
throw new AxisFault( "No operation name specified" );
try {
- String ns = (String) getProperty( Constants.NAMESPACE );
+ String ns = (String) getProperty( Call.NAMESPACE );
if ( ns == null )
return( this.invoke(operationName,getParamList(params)) );
else
@@ -533,17 +578,6 @@
category.info("Transport is " + transport);
}
- /**
- * Set the name of the transport chain to use.
- *
- * Note: Not part of JAX-RPC specification.
- */
- public void setTransportName(String name) {
- transportName = name ;
- if ( transport != null )
- transport.setTransportName( name );
- }
-
/** Get the Transport registered for the given protocol.
*
* Note: Not part of JAX-RPC specification.
@@ -567,28 +601,6 @@
}
/**
- * Set timeout in our MessageContext.
- *
- * Note: Not part of JAX-RPC specification.
- *
- * @param value the maximum amount of time, in milliseconds
- */
- public void setTimeout (int value) {
- timeout = value;
- }
-
- /**
- * Get timeout from our MessageContext.
- *
- * Note: Not part of JAX-RPC specification.
- *
- * @return value the maximum amount of time, in milliseconds
- */
- public int getTimeout () {
- return timeout;
- }
-
- /**
* Directly set the request message in our MessageContext.
*
* This allows custom message creation.
@@ -891,14 +903,23 @@
msgContext.reset();
- msgContext.setTimeout(timeout);
-
if (myProperties != null) {
Enumeration enum = myProperties.keys();
while (enum.hasMoreElements()) {
String name = (String) enum.nextElement();
Object value = myProperties.get(name);
- msgContext.setProperty(name, value);
+ int intValue = 0 ;
+
+ if ( name.equals( TIMEOUT ) ) {
+ if ( value instanceof Integer )
+ intValue = ((Integer)value).intValue();
+ else
+ intValue = Integer.parseInt((String)value);
+
+ msgContext.setTimeout( intValue );
+ }
+ else
+ msgContext.setProperty(name, value);
}
}
1.11 +2 -1 xml-axis/java/src/org/apache/axis/client/Service.java
Index: Service.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Service.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Service.java 2001/10/13 11:17:51 1.10
+++ Service.java 2001/10/15 19:24:00 1.11
@@ -375,7 +375,8 @@
SOAPBody sBody = (SOAPBody) obj ;
String tmp = sBody.getNamespaceURI();
if ( tmp != null )
- call.setProperty( Constants.NAMESPACE, tmp );
+ call.setProperty( org.apache.axis.client.Call.NAMESPACE,
+ tmp );
list = sBody.getEncodingStyles();
if ( list != null && list.size() > 0 )
call.setEncodingStyle( (String) list.get(0) );
1.11 +7 -0 xml-axis/java/src/org/apache/axis/message/SOAPBodyElement.java
Index: SOAPBodyElement.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBodyElement.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SOAPBodyElement.java 2001/10/03 15:30:05 1.10
+++ SOAPBodyElement.java 2001/10/15 19:24:01 1.11
@@ -56,8 +56,10 @@
*/
import org.apache.axis.encoding.DeserializationContext;
+import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Element;
import org.xml.sax.Attributes;
+import java.io.InputStream ;
/** A Body element.
*
@@ -80,5 +82,10 @@
public SOAPBodyElement()
{
+ }
+
+ public SOAPBodyElement(InputStream input)
+ {
+ super( XMLUtils.newDocument(input).getDocumentElement() );
}
}