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 ro...@apache.org on 2001/07/11 00:53:23 UTC
cvs commit: xml-axis/java/test/functional TestProxySample.java FunctionalTests.java TestStockSample.java
robj 01/07/10 15:53:23
Modified: java/samples/misc TestClient.java
java/samples/transport/tcp TCPListener.java TCPSender.java
java/src/org/apache/axis AxisEngine.java Message.java
MessageContext.java
java/src/org/apache/axis/client AxisClient.java
ServiceClient.java
java/src/org/apache/axis/message RPCParam.java
java/src/org/apache/axis/providers/java JavaProvider.java
MsgProvider.java
java/src/org/apache/axis/server AxisServer.java
server-config.xml
java/src/org/apache/axis/utils Admin.java
java/test build_functional_tests.xml
java/test/functional FunctionalTests.java
TestStockSample.java
Added: java/samples/proxy client_deploy.xml deploy.xml
ProxyService.java
java/test/functional TestProxySample.java
Log:
- Added new sample: an Axis proxy which redirects all
incoming messages to a specified URL.
- Added AxisEngine.getClientEngine() to support having
a single server-side AxisClient which is used by all server-
side ServiceClients.
- Added functional test for proxy sample.
Revision Changes Path
1.9 +34 -21 xml-axis/java/samples/misc/TestClient.java
Index: TestClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/misc/TestClient.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TestClient.java 2001/07/07 14:24:00 1.8
+++ TestClient.java 2001/07/10 22:52:26 1.9
@@ -71,14 +71,30 @@
* @author Glen Daniels (gdaniels@allaire.com)
*/
public class TestClient {
- public static String msg = "<m:GetLastTradePrice xmlns:m=\"Some-URI\">\n" +
- "<symbol>IBM</symbol>\n" +
- "</m:GetLastTradePrice>\n" ;
-
- public static String doTest (String args[]) throws Exception {
+ public static String msg = "<SOAP-ENV:Envelope " +
+ "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
+ "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" > " +
+ "<SOAP-ENV:Body>\n" +
+ "<echo:Echo xmlns:echo=\"EchoService\">\n" +
+ "<symbol>IBM</symbol>\n" +
+ "</echo:Echo>\n" +
+ "</SOAP-ENV:Body></SOAP-ENV:Envelope>\n";
+
+ /**
+ * Send a hardcoded message to the server, and print the response.
+ *
+ * @param args the command line arguments (mainly for specifying URL)
+ * @param service an optional service argument, which will be used for
+ * specifying the transport-level service
+ */
+ public static String doTest (String args[], String service) throws Exception {
Options opts = new Options( args );
String url = opts.getURL();
String action = "EchoService" ;
+
+ if (service != null) {
+ action = service;
+ }
Debug.setDebugLevel( opts.isFlagSet( 'd' ) );
@@ -89,26 +105,23 @@
client.set(HTTPTransport.URL, url);
client.set(HTTPTransport.ACTION, action);
- Message inMsg = new Message( msg );
- Message outMsg = null ;
+ Message reqMsg = new Message( msg );
+ Message resMsg = null ;
System.out.println( "Request:\n" + msg );
- client.setRequestMessage( inMsg );
+ client.setRequestMessage( reqMsg );
client.invoke();
- outMsg = client.getMessageContext().getResponseMessage();
+ resMsg = client.getMessageContext().getResponseMessage();
- System.out.println( "Response:\n" + outMsg.getAsString() );
- return (String)outMsg.getAsString();
+ System.out.println( "Response:\n" + resMsg.getAsString() );
+ return (String)resMsg.getAsString();
}
- public static void main(String args[]) {
- try {
- doTest(args);
- }
- catch( Exception e ) {
- if ( e instanceof AxisFault ) ((AxisFault)e).dump();
- else e.printStackTrace();
- }
- };
-};
+ public static void main(String args[]) throws Exception{
+ doTest(args, null);
+ }
+ public static void mainWithService(String args[], String service) throws Exception{
+ doTest(args, service);
+ }
+}
1.4 +2 -1 xml-axis/java/samples/transport/tcp/TCPListener.java
Index: TCPListener.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/TCPListener.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TCPListener.java 2001/06/27 16:18:10 1.3
+++ TCPListener.java 2001/07/10 22:52:32 1.4
@@ -112,7 +112,7 @@
System.exit(1);
}
- System.out.println("AxisListener is listening on port "+port+".");
+ System.out.println("TCPListener is listening on port "+port+".");
}
public void run () {
@@ -124,6 +124,7 @@
while (!done) {
try {
sock = srvSocket.accept();
+ System.out.println("TCPListener received new connection: "+sock);
new Thread(new SocketHandler(sock)).start();
} catch (IOException ex) {
/** stop complaining about this! it seems to happen on quit,
1.3 +2 -2 xml-axis/java/samples/transport/tcp/TCPSender.java
Index: TCPSender.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/TCPSender.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TCPSender.java 2001/06/29 18:43:17 1.2
+++ TCPSender.java 2001/07/10 22:52:33 1.3
@@ -78,7 +78,7 @@
*/
public class TCPSender extends BasicHandler {
public void invoke(MessageContext msgContext) throws AxisFault {
- Debug.Print( 1, "Enter: TCPSender::invoke" );
+ Debug.Print( 0, "Enter: TCPSender::invoke" );
/* Find the service we're invoking so we can grab it's options */
/***************************************************************/
String targetURL = null ;
@@ -140,7 +140,7 @@
if ( !(e instanceof AxisFault) ) e = new AxisFault(e);
throw (AxisFault) e ;
}
- Debug.Print( 1, "Exit: TCPSender::invoke" );
+ Debug.Print( 0, "Exit: TCPSender::invoke" );
}
public void undo(MessageContext msgContext) {
1.1 xml-axis/java/samples/proxy/client_deploy.xml
Index: client_deploy.xml
===================================================================
<m:clientdeploy xmlns:m="AdminService">
<handler name="TCPSender" class="samples.transport.tcp.TCPSender"/>
<handler name="LogIt" class="org.apache.axis.handlers.LogMessage">
<option name="message" value="Hey, I'm here!"/>
</handler>
<transport name="tcp" pivot="TCPSender" request="LogIt"/>
</m:clientdeploy>
1.1 xml-axis/java/samples/proxy/deploy.xml
Index: deploy.xml
===================================================================
<m:deploy xmlns:m="AdminService">
<chain name="proxyPivot" flow="MsgDispatcher" />
<!-- NEED TO DEPLOY HTTPActionHandler FOR THE FIRST TIME EVER?!?!?! - RobJ -->
<handler name="HTTPActionHandler" class="org.apache.axis.handlers.http.HTTPActionHandler"/>
<transport name="SimpleHTTP" pivot="HTTPSender" request="HTTPActionHandler" />
<service name="ProxyService" pivot="proxyPivot" >
<option name="className" value="samples.proxy.ProxyService" />
<option name="methodName" value="ProxyService" />
<option name="FullMessageService" value="true" />
<option name="URL" value="tcp://localhost:8088/" />
</service>
</m:deploy>
1.1 xml-axis/java/samples/proxy/ProxyService.java
Index: ProxyService.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package samples.proxy;
import java.util.*;
import org.w3c.dom.* ;
import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.Handler;
import org.apache.axis.client.ServiceClient;
import samples.transport.tcp.TCPTransport;
/**
* Proxy sample. Relays message on to hardcoded URL.
* Soon, URL becomes configurable (via deployment?!);
* later, URL becomes specifiable in custom header.
*
* @author Rob Jellinghaus <ro...@unrealities.com>
*/
public class ProxyService {
/**
* Process the given message, treating it as raw XML.
* -- is this sufficient???
*/
public Document ProxyService(MessageContext msgContext)
throws AxisFault
{
/*
// Look in the message context for our service...
// um... yeh
Handler self = msgContext.getServiceHandler();
// what is our target URL?
String dest = (String)self.getOption("URL");
// make a ServiceClient going in that direction
// (should we cache this?)
// (what about deployment of other transports?)
ServiceClient client = new ServiceClient(dest);
// try plain old simple handoff!!!
client.setRequestMessage(msgContext.getRequestMessage());
// send it!!!
client.invoke();
// hmm, will reverse handoff work?
msgContext.setResponseMessage(client.getMessageContext().getResponseMessage());
// return null so MsgProvider will not muck with our response
return null;
*/
Handler self = msgContext.getServiceHandler();
// for chat tomorrow:
String dest = (String)self.getOption("URL");
// use the server's client engine in case anything has been deployed to it
ServiceClient client = new ServiceClient(msgContext.getAxisEngine().getClientEngine());
// add TCP for proxy testing
client.addTransportPackage("samples.transport");
client.setTransportForProtocol("tcp", new TCPTransport());
// NOW set the client's URL (since now we know what transports we'll want)
client.setURL(dest);
client.setRequestMessage(msgContext.getRequestMessage());
client.invoke();
msgContext.setResponseMessage(client.getMessageContext().getResponseMessage());
// return null so MsgProvider will not muck with our response
return null;
}
}
1.23 +16 -3 xml-axis/java/src/org/apache/axis/AxisEngine.java
Index: AxisEngine.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- AxisEngine.java 2001/07/08 14:18:36 1.22
+++ AxisEngine.java 2001/07/10 22:52:40 1.23
@@ -158,14 +158,14 @@
/**
* Load up our engine's configuration of Handlers, Chains,
* Services, etc.
- *
+ *
* NOTE: Right now this can only read an "engine-config.xml" in an
* appropriate place on the classpath (org/apache/axis/client or
* org/apache/axis/server). This should be modified to do something like
* look in the server startup directory first, or perhaps check a
* system property for the repository location. (OK, now it checks the
* local directory first.)
- *
+ *
* We need to complete discussions about the packaging and deployment
* patterns for Axis before this code solidifies.
*/
@@ -180,7 +180,7 @@
if (is == null) {
// TODO: Deal with this in a nicer way...
- System.err.println("No engine configuration in " +
+ System.err.println("No engine configuration in " +
this.getClass().getPackage().getName() +
" - aborting!");
return;
@@ -253,6 +253,19 @@
return _typeMappingRegistry;
}
+ /*********************************************************************
+ * Client engine access
+ *
+ * An AxisEngine may define another specific AxisEngine to be used
+ * by newly created ServiceClients. For instance, a server may
+ * create an AxisClient and allow deployment to it. Then
+ * the server's services may create ServiceClient objects which
+ * can access the AxisClient's deployed handlers and transports.
+ *********************************************************************
+ */
+
+ public abstract AxisEngine getClientEngine ();
+
/*********************************************************************
* Administration and management APIs
*
1.36 +13 -9 xml-axis/java/src/org/apache/axis/Message.java
Index: Message.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- Message.java 2001/07/10 03:30:47 1.35
+++ Message.java 2001/07/10 22:52:41 1.36
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -85,6 +85,10 @@
private static final int FORM_BODYINSTREAM = 5;
private static final int FORM_FAULT = 6;
private int currentForm ;
+
+ private static final String[] formNames =
+ { "", "FORM_STRING", "FORM_INPUTSTREAM", "FORM_SOAPENVELOPE",
+ "FORM_BYTES", "FORM_BODYINSTREAM", "FORM_FAULT" };
private String messageType ;
private MessageContext msgContext;
@@ -156,7 +160,7 @@
}
private void setCurrentMessage(Object currMsg, int form) {
- Debug.Print( 2, "Setting current message form to: " + form );
+ Debug.Print( 2, "Setting current message form to: " + formNames[form] +" (currentMessage is now "+currMsg+")" );
currentMessage = currMsg ;
currentForm = form ;
}
@@ -214,7 +218,7 @@
public String getAsString() {
Debug.Print( 2, "Enter: Message::getAsString" );
if ( currentForm == FORM_STRING ) {
- Debug.Print( 2, "Exit: Message::getAsString" );
+ Debug.Print( 2, "Exit: Message::getAsString, currentMessage is "+currentMessage );
return( (String) currentMessage );
}
@@ -226,7 +230,7 @@
if ( currentForm == FORM_BYTES ) {
setCurrentMessage( new String((byte[]) currentMessage), FORM_STRING );
- Debug.Print( 2, "Exit: Message::getAsString" );
+ Debug.Print( 2, "Exit: Message::getAsString, currentMessage is "+currentMessage );
return( (String) currentMessage );
}
@@ -262,8 +266,8 @@
}
public SOAPEnvelope getAsSOAPEnvelope() {
- Debug.Print( 2, "Enter: Message::getAsSOAPEnvelope" );
- if ( currentForm == FORM_SOAPENVELOPE )
+ Debug.Print( 2, "Enter: Message::getAsSOAPEnvelope; currentForm is "+formNames[currentForm] );
+ if ( currentForm == FORM_SOAPENVELOPE )
return( (SOAPEnvelope) currentMessage );
if (currentForm == FORM_BODYINSTREAM) {
1.43 +12 -12 xml-axis/java/src/org/apache/axis/MessageContext.java
Index: MessageContext.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- MessageContext.java 2001/07/08 14:18:36 1.42
+++ MessageContext.java 2001/07/10 22:52:42 1.43
@@ -95,13 +95,13 @@
* Just a placeholder until we figure out how many messages we'll actually
* be passing around.
*/
- private Message inMessage ;
+ private Message requestMessage ;
/**
* Just a placeholder until we figure out how many messages we'll actually
* be passing around.
*/
- private Message outMessage ;
+ private Message responseMessage ;
/**
* That unique key/name that the next router/dispatch handler should use
@@ -160,11 +160,11 @@
/**
* Get the currently in-scope type mapping registry.
- *
+ *
* By default, will return a reference to the AxisEngine's TMR until
* someone sets our local one (usually as a result of setting the
* serviceHandler).
- *
+ *
* @return the type mapping registry to use for this request.
*/
public TypeMappingRegistry getTypeMappingRegistry() {
@@ -231,28 +231,28 @@
* Placeholder.
*/
public Message getRequestMessage() {
- return inMessage ;
+ return requestMessage ;
};
/**
* Placeholder.
*/
- public void setRequestMessage(Message inMsg) {
- inMessage = inMsg ;
- if (inMessage != null) inMessage.setMessageContext(this);
+ public void setRequestMessage(Message reqMsg) {
+ requestMessage = reqMsg ;
+ if (requestMessage != null) requestMessage.setMessageContext(this);
};
/**
* Placeholder.
*/
- public Message getResponseMessage() { return outMessage ; }
+ public Message getResponseMessage() { return responseMessage ; }
/**
* Placeholder.
*/
- public void setResponseMessage(Message outMsg) {
- outMessage = outMsg ;
- if (outMessage != null) outMessage.setMessageContext(this);
+ public void setResponseMessage(Message respMsg) {
+ responseMessage = respMsg ;
+ if (responseMessage != null) responseMessage.setMessageContext(this);
};
public AxisClassLoader getClassLoader() {
1.19 +8 -1 xml-axis/java/src/org/apache/axis/client/AxisClient.java
Index: AxisClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/AxisClient.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- AxisClient.java 2001/06/29 13:14:33 1.18
+++ AxisClient.java 2001/07/10 22:52:47 1.19
@@ -80,6 +80,13 @@
}
/**
+ * this *is* the client engine!
+ */
+ public AxisEngine getClientEngine () {
+ return this;
+ }
+
+ /**
* Main routine of the AXIS engine. In short we locate the appropriate
* handler for the desired service and invoke() it.
*/
@@ -142,7 +149,7 @@
h.invoke(msgContext);
/** Process the Transport Specific stuff
- *
+ *
* NOTE: Somewhere in here there is a handler which actually
* sends the message and receives a response. Generally
* this is the pivot point in the Transport chain.
1.30 +46 -16 xml-axis/java/src/org/apache/axis/client/ServiceClient.java
Index: ServiceClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/ServiceClient.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- ServiceClient.java 2001/07/10 03:30:48 1.29
+++ ServiceClient.java 2001/07/10 22:52:48 1.30
@@ -165,7 +165,7 @@
*/
// Our AxisClient
- private AxisClient engine;
+ private AxisEngine engine;
// The description of our service
private ServiceDescription serviceDesc;
@@ -180,11 +180,19 @@
* Basic, no-argument constructor.
*/
public ServiceClient () {
- engine = new AxisClient();
+ this(new AxisClient());
+ }
+
+ /**
+ * Construct a ServiceClient with just an AxisEngine.
+ */
+ public ServiceClient (AxisEngine engine) {
+ this.engine = engine;
msgContext = new MessageContext(engine);
if (!initialized)
initialize();
}
+
/**
* Construct a ServiceClient with a given endpoint URL
@@ -194,18 +202,16 @@
*/
public ServiceClient(String endpointURL)
{
- this();
-
- try {
- URL url = new URL(endpointURL);
- String protocol = url.getProtocol();
- setTransport(getTransportForProtocol(protocol));
- set(MessageContext.TRANS_URL, endpointURL);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
+ this(endpointURL, new AxisClient());
+ }
+
+ /**
+ * Construct a ServiceClient with a given endpoint URL & engine
+ */
+ public ServiceClient(String endpointURL, AxisEngine engine)
+ {
+ this(engine);
+ this.setURL(endpointURL);
}
/**
@@ -216,7 +222,14 @@
* request
*/
public ServiceClient (Transport transport) {
- this();
+ this(transport, new AxisClient());
+ }
+
+ /**
+ * Construct a ServiceClient with the given Transport & engine.
+ */
+ public ServiceClient (Transport transport, AxisEngine engine) {
+ this(engine);
setTransport(transport);
}
@@ -230,8 +243,25 @@
this.transport = transport;
Debug.Print(1, "Transport is " + transport);
}
+
+ /**
+ * Set the URL (and the transport state).
+ */
+ public void setURL (String endpointURL)
+ {
+ try {
+ URL url = new URL(endpointURL);
+ String protocol = url.getProtocol();
+ setTransport(getTransportForProtocol(protocol));
+ set(MessageContext.TRANS_URL, endpointURL);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- /** Get the Transport registered for the given protocol.
+ /** Get the Transport registered for the given protocol.
*
* @param protocol a protocol such as "http" or "local" which may
* have a Transport object associated with it.
1.19 +10 -7 xml-axis/java/src/org/apache/axis/message/RPCParam.java
Index: RPCParam.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- RPCParam.java 2001/06/21 15:06:28 1.18
+++ RPCParam.java 2001/07/10 22:52:53 1.19
@@ -4,7 +4,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -12,7 +12,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -20,7 +20,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -28,7 +28,7 @@
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -65,7 +65,7 @@
import org.xml.sax.helpers.DefaultHandler;
/** An RPC parameter element.
- *
+ *
* @author Glen Daniels (gdaniels@macromedia.com)
*/
public class RPCParam extends MessageElement
@@ -160,8 +160,11 @@
"CDATA", "1");
}
- if (typeQName == null)
- typeQName = context.getQNameForClass(value.getClass());
+ // don't try to get typeQName unless value is non-null!
+ if (typeQName == null && value != null) {
+ Class clazz = value.getClass();
+ typeQName = context.getQNameForClass(clazz);
+ }
context.serialize(new QName(getNamespaceURI(), getName()), attrs, value);
}
1.6 +3 -1 xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
Index: JavaProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JavaProvider.java 2001/07/08 14:18:38 1.5
+++ JavaProvider.java 2001/07/10 22:52:58 1.6
@@ -229,7 +229,9 @@
processMessage(msgContext, serviceName, methodName, reqEnv, resEnv, jc, obj);
- if (resMsg == null) {
+ // get the response message again! it may have been explicitly set!
+ // (by, say, a proxy service :-) -- RobJ
+ if (msgContext.getResponseMessage() == null) {
resMsg = new Message(resEnv);
msgContext.setResponseMessage( resMsg );
}
1.3 +63 -21 xml-axis/java/src/org/apache/axis/providers/java/MsgProvider.java
Index: MsgProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/MsgProvider.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MsgProvider.java 2001/07/08 14:18:38 1.2
+++ MsgProvider.java 2001/07/10 22:52:59 1.3
@@ -68,6 +68,7 @@
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.message.SOAPHeader;
import org.apache.axis.handlers.* ;
+import org.apache.axis.Handler;
import org.w3c.dom.* ;
import org.xml.sax.*;
@@ -87,37 +88,78 @@
SOAPEnvelope reqEnv,
SOAPEnvelope resEnv,
JavaClass jc,
+
Object obj)
throws Exception
{
- Class[] argClasses = new Class[2];
- Object[] argObjects = new Object[2];
+ Handler targetService = msgContext.getServiceHandler();
- SOAPBodyElement reqBody = reqEnv.getFirstBody();
+ // is this service a body-only service?
+ // if true (the default), the servic3e expects two args,
+ // a MessageContext and a Document which is the contents of the first body element.
+ // if false, the service expects just one MessageContext argument,
+ // and looks at the entire request envelope in the MessageContext
+ // (hence it's a "FullMessageService").
+ boolean bodyOnlyService = true;
+ if (targetService.getOption("FullMessageService") != null) {
+ bodyOnlyService = false;
+ }
+
+ Class[] argClasses;
+ Object[] argObjects;
- StringWriter writer = new StringWriter();
- reqBody.output(new SerializationContext(writer, msgContext));
+ /** !!! KLUDGE WARNING
+ * We need some way of associating ServiceDescriptions with actual
+ * services... and then at the point when we figure out which service
+ * we'll be calling (which might be right away (static dispatch), after
+ * looking at the URL (transport-level dispatch), or even after looking
+ * into the SOAP message itself...)
+ */
+ if (clsName.equals("org.apache.axis.utils.Admin")) {
+ ServiceDescription sd = new ServiceDescription("Admin", false);
+ msgContext.setServiceDescription(sd);
+ }
- Reader reader = new StringReader(writer.getBuffer().toString());
- Document doc = XMLUtils.newDocument(new InputSource(reader));
+ // the document which is the contents of the first body element
+ // (generated only if we are not an envelope service)
+ Document doc;
+
+ if (bodyOnlyService) {
+ // dig out just the body, and pass it with the MessageContext
+ argClasses = new Class[2];
+ argObjects = new Object[2];
+ SOAPBodyElement reqBody = reqEnv.getFirstBody();
+
+ StringWriter writer = new StringWriter();
+ reqBody.output(new SerializationContext(writer, msgContext));
+
+ Reader reader = new StringReader(writer.getBuffer().toString());
+ doc = XMLUtils.newDocument(new InputSource(reader));
+
+ /* If no methodName was specified during deployment then get it */
+ /* from the root of the Body element */
+ /* Hmmm, should we do this???? */
+ /****************************************************************/
+ if ( methodName == null || methodName.equals("") ) {
+ Element root = doc.getDocumentElement();
+ if ( root != null ) methodName = root.getLocalName();
+ }
+ argClasses[0] = msgContext.getClassLoader().loadClass("org.apache.axis.MessageContext");
+ argClasses[1] = msgContext.getClassLoader().loadClass("org.w3c.dom.Document");
+ argObjects[0] = msgContext ;
+ argObjects[1] = doc ;
+ } else {
+ // pass *just* the MessageContext (maybe don't even parse!!!)
+ argClasses = new Class[1];
+ argObjects = new Object[1];
+ argClasses[0] = msgContext.getClassLoader().loadClass("org.apache.axis.MessageContext");
+ argObjects[0] = msgContext ;
+ }
+
// !!! WANT TO MAKE THIS SAX-CAPABLE AS WELL. Some people will
// want DOM, but our examples should mostly lean towards the
// SAX side of things....
-
- /* If no methodName was specified during deployment then get it */
- /* from the root of the Body element */
- /* Hmmm, should we do this???? */
- /****************************************************************/
- if ( methodName == null || methodName.equals("") ) {
- Element root = doc.getDocumentElement();
- if ( root != null ) methodName = root.getLocalName();
- }
-
- argClasses[0] = msgContext.getClassLoader().loadClass("org.apache.axis.MessageContext");
- argClasses[1] = msgContext.getClassLoader().loadClass("org.w3c.dom.Document");
- argObjects[0] = msgContext ;
- argObjects[1] = doc ;
Method method = jc.getJavaClass().getMethod( methodName, argClasses );
1.30 +20 -0 xml-axis/java/src/org/apache/axis/server/AxisServer.java
Index: AxisServer.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/AxisServer.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- AxisServer.java 2001/06/29 13:14:35 1.29
+++ AxisServer.java 2001/07/10 22:53:04 1.30
@@ -65,6 +65,10 @@
import org.apache.axis.encoding.SOAPTypeMappingRegistry;
import org.apache.axis.encoding.TypeMappingRegistry;
+// This is included in order to support getClientEngine()
+import org.apache.axis.client.AxisClient;
+
+
import org.apache.axis.transport.http.HTTPSender;
import org.apache.axis.providers.java.*;
/**
@@ -74,6 +78,11 @@
*/
public class AxisServer extends AxisEngine
{
+ /**
+ * the AxisClient to be used by outcalling Services
+ */
+ private AxisEngine clientEngine;
+
public AxisServer()
{
super(Constants.SERVER_CONFIG_FILE);
@@ -111,6 +120,17 @@
public void stop()
{
running = false;
+ }
+
+ /**
+ * Get this server's client engine. Create it if it does
+ * not yet exist.
+ */
+ public synchronized AxisEngine getClientEngine () {
+ if (clientEngine == null) {
+ clientEngine = new AxisClient();
+ }
+ return clientEngine;
}
/**
1.4 +1 -1 xml-axis/java/src/org/apache/axis/server/server-config.xml
Index: server-config.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/server-config.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- server-config.xml 2001/07/09 21:31:51 1.3
+++ server-config.xml 2001/07/10 22:53:06 1.4
@@ -33,4 +33,4 @@
</services>
-</engineConfig>
\ No newline at end of file
+</engineConfig>
1.53 +22 -16 xml-axis/java/src/org/apache/axis/utils/Admin.java
Index: Admin.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- Admin.java 2001/07/08 14:18:39 1.52
+++ Admin.java 2001/07/10 22:53:10 1.53
@@ -81,7 +81,7 @@
/**
* Fill in options for a given handler.
- *
+ *
* @param root the element containing the options
* @param handler the Handler to set options on
*/
@@ -111,7 +111,7 @@
/**
* Register a set of type mappings for a service.
- *
+ *
* @param root the Element containing the service configuration
* @param service the SOAPService we're working with.
*/
@@ -159,7 +159,7 @@
/** Process an engine configuration file by deploying appropriate stuff
* into the specified AxisEngine, and then telling it to save itself
* when we're done.
- *
+ *
* @param doc an XML document containing an Axis engine configuration
* @param engine the AxisEngine in which to deploy
* @exception Exception (should be DeploymentException?)
@@ -194,12 +194,12 @@
}
/** Deploy a set of individual items.
- *
+ *
* NOTE: as it stands this doesn't care about the relationship between
* these items and the enclosing tag. We shouldn't really allow <service>
* deployment underneath the <transports> tag, for instance. Since this
* is going to mutate some more, this is the simple way to do it for now.
- *
+ *
* @param nl a DOM NodeList of deployable items.
* @param engine the AxisEngine into which we deploy.
* @exception Exception (should be DeploymentException?)
@@ -238,7 +238,7 @@
/**
* The meat of the Admin service. Process an xML document rooted with
* a "deploy", "undeploy", "list", or "quit" element.
- *
+ *
* @param msgContext the MessageContext we're processing
* @param root the root Element of the XML
* @return an XML Document indicating the results.
@@ -256,10 +256,11 @@
String action = root.getLocalName();
AxisClassLoader cl = AxisClassLoader.getClassLoader();
- if ( !action.equals("deploy") && !action.equals("undeploy") &&
+ if ( !action.equals("clientdeploy") && !action.equals("deploy") &&
+ !action.equals("undeploy") &&
!action.equals("list") && !action.equals("quit") )
throw new AxisFault( "Admin.error",
- "Root element must be 'deploy', 'undeploy', " +
+ "Root element must be 'clientdeploy', 'deploy', 'undeploy', " +
"'list', or 'quit'",
null, null );
@@ -279,6 +280,11 @@
if ( action.equals("list") ) {
return listConfig(engine);
}
+
+ if (action.equals("clientdeploy")) {
+ // set engine to client engine
+ engine = engine.getClientEngine();
+ }
NodeList list = root.getChildNodes();
for ( int loop = 0 ; loop < list.getLength() ; loop++ ) {
@@ -348,10 +354,10 @@
}
/** Get an XML document representing this engine's configuration.
- *
+ *
* This document is suitable for saving and reloading into the
* engine.
- *
+ *
* @param engine the AxisEngine to work with
* @return an XML document holding the engine config
* @exception AxisFault
@@ -387,7 +393,7 @@
/**
* Return an XML Element containing the configuration info for one
* of the engine's Handler registries.
- *
+ *
* @param root the Element to work with (same as the one we return)
* @param registry the registry to write into this Element
* @return Element our config element, suitable for pumping back through
@@ -423,7 +429,7 @@
/**
* Deploy a chain described in XML into an AxisEngine.
- *
+ *
* @param elem the <chain> element
* @param engine the AxisEngine in which to deploy
*/
@@ -504,7 +510,7 @@
/**
* Deploy a service described in XML into an AxisEngine.
- *
+ *
* @param elem the <service> element
* @param engine the AxisEngine in which to deploy
*/
@@ -600,7 +606,7 @@
/**
* Deploy a handler described in XML into an AxisEngine.
- *
+ *
* @param elem the <handler> element
* @param engine the AxisEngine in which to deploy
*/
@@ -635,7 +641,7 @@
/**
* Deploy a transport described in XML into an AxisEngine.
- *
+ *
* @param elem the <transport> element
* @param engine the AxisEngine in which to deploy
*/
@@ -686,7 +692,7 @@
/**
* Deploy a type mapping described in XML.
- *
+ *
* @param root the type mapping element.
* @param map the TypeMappingRegistry which gets this mapping.
*/
1.8 +3 -1 xml-axis/java/test/build_functional_tests.xml
Index: build_functional_tests.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/test/build_functional_tests.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- build_functional_tests.xml 2001/07/08 14:18:39 1.7
+++ build_functional_tests.xml 2001/07/10 22:53:15 1.8
@@ -30,7 +30,9 @@
<pathelement path="${java.class.path}" />
</path>
- <taskdef name="runaxisfunctionaltests" classname="test.functional.ant.RunAxisFunctionalTestsTask" />
+ <taskdef name="runaxisfunctionaltests"
+ classname="test.functional.ant.RunAxisFunctionalTestsTask"
+ classpath="${build.dir}" />
<!-- =================================================================== -->
<!-- Launches the functional test TCP server -->
1.7 +8 -2 xml-axis/java/test/functional/FunctionalTests.java
Index: FunctionalTests.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/FunctionalTests.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FunctionalTests.java 2001/07/03 20:22:03 1.6
+++ FunctionalTests.java 2001/07/10 22:53:18 1.7
@@ -5,7 +5,7 @@
import junit.framework.TestSuite;
/**
- * soapenc's FunctionalTests test client/server interactions.
+ * Axis's FunctionalTests test client/server interactions.
*/
public class FunctionalTests extends TestCase
{
@@ -18,7 +18,7 @@
{
TestSuite suite = new TestSuite();
- // Echo test - end to end serialization and deserialization /
+ // Echo test - end to end serialization and deserialization /
// interop tests.
suite.addTestSuite(TestEchoSample.class);
@@ -39,6 +39,12 @@
// address book test
suite.addTestSuite(TestAddressBookSample.class);
+
+ // "Raw" echo service test.
+ suite.addTestSuite(TestMiscSample.class);
+
+ // Proxy service test.
+ suite.addTestSuite(TestProxySample.class);
return suite;
}
1.6 +4 -2 xml-axis/java/test/functional/TestStockSample.java
Index: TestStockSample.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/TestStockSample.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestStockSample.java 2001/07/08 14:18:40 1.5
+++ TestStockSample.java 2001/07/10 22:53:19 1.6
@@ -88,8 +88,9 @@
args[3] = "-sjws/AltStockQuoteService.jws";
try {
val = new GetQuote().getQuote(args);
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (AxisFault e) {
+ // Don't print stack trace unless there is an error
+ // e.printStackTrace();
return;
}
assertNull("not null");
@@ -141,4 +142,5 @@
}
}
+
1.1 xml-axis/java/test/functional/TestProxySample.java
Index: TestProxySample.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package test.functional;
import java.net.*;
import java.io.*;
import java.util.*;
import org.apache.axis.AxisFault ;
import org.apache.axis.utils.Debug ;
import org.apache.axis.utils.Options ;
import org.apache.axis.client.AdminClient;
import org.apache.axis.client.ServiceClient;
import junit.framework.TestCase;
import samples.misc.TestClient;
/** Test the proxy sample code.
*/
public class TestProxySample extends TestCase {
public TestProxySample(String name) {
super(name);
}
public void doTest () throws Exception {
String[] args = { "-d" };
TestClient.mainWithService(args, "ProxyService");
}
// temp for debugging
public static void main (String[] args) throws Exception {
new TestProxySample("foo").doTest();
}
public void testService () throws Exception {
try {
System.out.println("Testing proxy sample.");
System.out.println("Testing deployment...");
// deploy the proxy service
String[] args = { "samples/proxy/deploy.xml" };
AdminClient.main(args);
System.out.println("Testing server-side client deployment...");
// deploy the proxy service
String[] args2 = { "samples/proxy/client_deploy.xml" };
AdminClient.main(args2);
// mysterious magic -- RobJ
ServiceClient.addTransportPackage("samples.transport");
System.out.println("Testing service...");
doTest();
System.out.println("Test complete.");
}
catch( Exception e ) {
if ( e instanceof AxisFault ) ((AxisFault)e).dump();
e.printStackTrace();
throw new Exception("Fault returned from test: "+e);
}
}
}