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 ru...@apache.org on 2002/01/03 19:08:29 UTC
cvs commit: xml-axis/java/test/session TestSimpleSession.java
rubys 02/01/03 10:08:29
Modified: java/samples/proxy ProxyService.java
java/samples/transport FileTest.java
java/samples/transport/tcp AdminClient.java GetQuote.java
TCPListener.java
java/src/org/apache/axis SimpleTargetedChain.java
TargetedChain.java
java/src/org/apache/axis/deployment/v2dd
V2DDDeployableItem.java
java/src/org/apache/axis/deployment/wsdd WSDDService.java
WSDDTargetedChain.java
java/src/org/apache/axis/handlers/soap SOAPService.java
java/src/org/apache/axis/server Transport.java
java/test/functional TestTCPTransportSample.java
java/test/session TestSimpleSession.java
Log:
1. The most important reason for the patch is to allow more consistent use
of terminology. Without the patch TargetedChain is not strictly a Chain at
all (i.e. the TargetedChain interface doesn't extend the Chain interface),
so its name is rather misleading. Renaming TargetedChain to avoid referring
to Chain doesn't help as the concepts are so close. I believe that a
TargetedChain really is a special type of Chain with separately
identifiable requst, pivot, and response handlers. Similarly,
SimpleTargetedChain is really a special type of SimpleChain as its name
implies and the patch enshrines this in the code by making the former
extend the latter.
2. SimpleTargetedChain is initialised in stages which allows it to appear
in partially initialised states, e.g. with the request handler set but
without the response handler. This is changed to provide explicit
constructors which take the appropriate number of parameters and produce
valid SimpleTargetedChain instances. The error checking code in SOAPService
to cope with partially initialised states is then unnecessary.
3. There is quite a bit of duplicated logic between SimpleTargetedChain and
SimpleChain which can be deleted once the former is changed to extend the
latter. The result is easier to maintain. For example, if we rename undo or
modify its behaviour, we will not have to touch SimpleTargetedChain as it
will inherit its undo behaviour from SimpleChain.
4. There is also duplicated logic between SimpleTargetedChain and
SOAPService. In the patch, the additional logic has been separated out into
a Handler inside SOAPService which then allows the standard behaviour of
SimpleChain invoke (and undo) to be inherited.
Submitted by: Glyn Normington <gl...@uk.ibm.com>
Revision Changes Path
1.11 +1 -2 xml-axis/java/samples/proxy/ProxyService.java
Index: ProxyService.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/proxy/ProxyService.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ProxyService.java 3 Dec 2001 22:49:22 -0000 1.10
+++ ProxyService.java 3 Jan 2002 18:08:28 -0000 1.11
@@ -94,8 +94,7 @@
service.setEngine( msgContext.getAxisEngine().getClientEngine() );
Call call = (Call) service.createCall();
- SimpleTargetedChain c = new SimpleTargetedChain();
- c.setPivotHandler(new TCPSender());
+ SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
service.getEngine().deployTransport("tcp", c);
// add TCP for proxy testing
1.21 +1 -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.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- FileTest.java 26 Nov 2001 02:21:38 -0000 1.20
+++ FileTest.java 3 Jan 2002 18:08:28 -0000 1.21
@@ -37,8 +37,7 @@
AxisEngine engine = service.getEngine();
// Manually deploy file sender and file transport for this example
- SimpleTargetedChain c = new SimpleTargetedChain();
- c.setPivotHandler(new FileSender());
+ SimpleTargetedChain c = new SimpleTargetedChain(new FileSender());
engine.deployTransport("FileTransport", c);
call.setOperationName( "getQuote" );
1.12 +1 -2 xml-axis/java/samples/transport/tcp/AdminClient.java
Index: AdminClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/AdminClient.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AdminClient.java 15 Nov 2001 19:48:42 -0000 1.11
+++ AdminClient.java 3 Jan 2002 18:08:28 -0000 1.12
@@ -77,8 +77,7 @@
org.apache.axis.client.AdminClient client =
new org.apache.axis.client.AdminClient(System.err);
- SimpleTargetedChain c = new SimpleTargetedChain();
- c.setPivotHandler(new TCPSender());
+ SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
client.getCall().getService().getEngine().deployTransport("tcp", c);
System.out.println(client.process(args));
1.14 +1 -2 xml-axis/java/samples/transport/tcp/GetQuote.java
Index: GetQuote.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/transport/tcp/GetQuote.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- GetQuote.java 15 Nov 2001 19:48:42 -0000 1.13
+++ GetQuote.java 3 Jan 2002 18:08:28 -0000 1.14
@@ -93,8 +93,7 @@
Service service = new Service();
Call call = (Call)service.createCall();
- SimpleTargetedChain c = new SimpleTargetedChain();
- c.setPivotHandler(new TCPSender());
+ SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
service.getEngine().deployTransport("tcp", c);
call.setTransport(new TCPTransport());
1.14 +1 -2 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TCPListener.java 3 Dec 2001 22:49:22 -0000 1.13
+++ TCPListener.java 3 Jan 2002 18:08:28 -0000 1.14
@@ -155,8 +155,7 @@
engine = new AxisServer();
engine.init();
- SimpleTargetedChain c = new SimpleTargetedChain();
- c.setPivotHandler(new TCPSender());
+ SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
try {
engine.deployTransport(transportName, c);
1.34 +81 -207 xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java
Index: SimpleTargetedChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- SimpleTargetedChain.java 7 Dec 2001 18:30:27 -0000 1.33
+++ SimpleTargetedChain.java 3 Jan 2002 18:08:28 -0000 1.34
@@ -67,217 +67,91 @@
/**
*
* @author Doug Davis (dug@us.ibm.com)
+ * @author Glyn Normington (norm@uk.ibm.com)
*/
-public class SimpleTargetedChain extends BasicHandler implements TargetedChain
+public class SimpleTargetedChain extends SimpleChain implements TargetedChain
{
static Category category =
Category.getInstance(SimpleTargetedChain.class.getName());
- protected Handler requestHandler ;
- protected Handler pivotHandler ;
- protected Handler responseHandler ;
-
- public void init() {
- if ( requestHandler != null ) requestHandler.init();
- if ( pivotHandler != null ) pivotHandler.init();
- if ( responseHandler != null ) responseHandler.init();
- }
-
- public void cleanup() {
- if ( requestHandler != null ) requestHandler.cleanup();
- if ( pivotHandler != null ) pivotHandler.cleanup();
- if ( responseHandler != null ) responseHandler.cleanup();
- }
-
- /**
- * Invoke the request chain, pivot handler and response chain. If there's
- * a fault we need to make sure that we undo any completed handler
- * that has been successfully invoked and then rethrow the fault.
- */
- public void invoke(MessageContext msgContext) throws AxisFault {
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::invoke") );
- }
-
- if ( requestHandler != null ) requestHandler.invoke( msgContext );
- try {
- if ( pivotHandler != null ) pivotHandler.invoke( msgContext );
- }
- catch( Exception e ) {
- category.error( "SimpleTargetedChain caught exception", e );
- if ( requestHandler != null )
- requestHandler.undo( msgContext );
- throw AxisFault.makeFault(e);
- }
- msgContext.setPastPivot(true);
- try {
- if ( responseHandler != null )
- responseHandler.invoke( msgContext );
- }
- catch( Exception e ) {
- category.error( e );
- if ( pivotHandler != null ) pivotHandler.undo( msgContext );
- if ( requestHandler != null )
- requestHandler.undo( msgContext );
- throw AxisFault.makeFault(e);
- }
-
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::invoke") );
- }
- }
-
- public void generateWSDL(MessageContext msgContext) throws AxisFault {
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::editWSDL") );
- }
-
- if ( requestHandler != null ) requestHandler.generateWSDL( msgContext );
- try {
- if ( pivotHandler != null ) pivotHandler.generateWSDL( msgContext );
- }
- catch( Exception e ) {
- category.error( e );
- if ( requestHandler != null )
- requestHandler.undo( msgContext );
- throw AxisFault.makeFault(e);
- }
- msgContext.setPastPivot(true);
- try {
- if ( responseHandler != null )
- responseHandler.generateWSDL( msgContext );
- }
- catch( Exception e ) {
- category.error( e );
- throw AxisFault.makeFault(e);
- }
-
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::editWSDL") );
- }
- }
-
- /**
- * Undo all of the work - in reverse order.
- */
- public void undo(MessageContext msgContext) {
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::undo") );
- }
-
- if ( responseHandler != null ) responseHandler.undo( msgContext );
- if ( pivotHandler != null ) pivotHandler.undo( msgContext );
- if ( requestHandler != null ) requestHandler.undo( msgContext );
-
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::undo") );
- }
- }
-
- public boolean canHandleBlock(QName qname) {
- // TODO !!! : Need to look at this logic
- return ((requestHandler==null) ? false :
- (requestHandler.canHandleBlock(qname) ||
- (pivotHandler==null)) ? false :
- (pivotHandler.canHandleBlock(qname) ||
- (responseHandler==null)) ? false :
- responseHandler.canHandleBlock(qname) );
- }
-
- public Handler getRequestHandler() { return( requestHandler ); }
-
- public void setRequestHandler(Handler reqHandler)
- {
- requestHandler = reqHandler;
- }
-
- public Handler getPivotHandler() { return( pivotHandler ); }
-
- public void setPivotHandler(Handler handler) { pivotHandler = handler ; }
-
- public Handler getResponseHandler() { return( responseHandler ); }
-
- public void setResponseHandler(Handler respHandler)
- {
- responseHandler = respHandler;
- }
-
- public void clear() {
- requestHandler = null ;
- pivotHandler = null ;
- responseHandler = null ;
- }
-
- public Element getDeploymentData(Document doc) {
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("enter00", "SimpleTargetedChain::getDeploymentData") );
- }
-
- Element root = doc.createElementNS("", "chain");
- fillInDeploymentData(root);
-
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("exit00", "SimpleTargetedChain::getDeploymentData") );
- }
- return( root );
- }
-
- /**
- * Used by subclasses (i.e. SOAPService) to fill in deployment
- * data into an Element which might not be named "chain".
- *
- * @param root the Element to fill in with deployment data.
- */
- public void fillInDeploymentData(Element root)
- {
- Document doc = root.getOwnerDocument();
- StringBuffer str = new StringBuffer();
- Handler h ;
-
- if ( requestHandler != null ) {
- if (requestHandler instanceof Chain) {
- Handler[] handlers = ((Chain)requestHandler).getHandlers();
- str = new StringBuffer();
- for ( int i = 0 ; i < handlers.length ; i++ ) {
- h = (Handler) handlers[i];
- if ( i != 0 ) str.append(",");
- str.append( h.getName() );
- }
- } else {
- str.append(requestHandler.getName());
- }
- root.setAttribute( "request", str.toString() );
- }
- if ( pivotHandler != null ) {
- root.setAttribute( "pivot", pivotHandler.getName() );
- }
- if ( responseHandler != null ) {
- if (responseHandler instanceof Chain) {
- Handler[] handlers = ((Chain)responseHandler).getHandlers();
- str = new StringBuffer();
- for ( int i = 0 ; i < handlers.length ; i++ ) {
- h = (Handler) handlers[i];
- if ( i != 0 ) str.append(",");
- str.append( h.getName() );
- }
- } else {
- str.append(responseHandler.getName());
- }
- root.setAttribute( "response", str.toString() );
- }
-
- options = this.getOptions();
- if ( options != null ) {
- Enumeration e = options.keys();
- while ( e.hasMoreElements() ) {
- String k = (String) e.nextElement();
- Object v = options.get(k);
- Element e1 = doc.createElementNS("", "option");
- e1.setAttribute( "name", k );
- e1.setAttribute( "value", v.toString() );
- root.appendChild( e1 );
- }
- }
- }
+ protected Handler requestHandler ;
+ protected Handler pivotHandler ;
+ protected Handler responseHandler ;
+
+ /**
+ * Pivot indicator sets "past pivot point" before the response handler
+ * runs. This avoids having to reimplement SimpleChain.invoke and
+ * SimpleChain.generateWSDL.
+ */
+ private class PivotIndicator extends BasicHandler {
+ public PivotIndicator() {}
+
+ public void undo(MessageContext msgContext) {}
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ msgContext.setPastPivot(true);
+ }
+ }
+
+ /**
+ * Default no-arg constructor.
+ */
+ public SimpleTargetedChain() {}
+
+ /**
+ * Constructor for an instance with effectively only a pivot handler.
+ */
+ public SimpleTargetedChain(Handler handler) {
+ pivotHandler = handler;
+ if (pivotHandler != null) {
+ addHandler(pivotHandler);
+ addHandler(new PivotIndicator());
+ }
+ }
+
+ /**
+ * Constructor which takes real or null request, pivot, and response
+ * handlers.
+ */
+ public SimpleTargetedChain(Handler reqHandler, Handler pivHandler,
+ Handler respHandler) {
+ init(reqHandler, null, pivHandler, null, respHandler);
+ }
+
+ /**
+ * Initialiser which takes real or null request, pivot, and response
+ * handlers and which allows for special request and response
+ * handlers to be inserted just before and after any pivot handler.
+ */
+ protected void init(Handler reqHandler, Handler specialReqHandler,
+ Handler pivHandler, Handler specialRespHandler,
+ Handler respHandler) {
+
+ requestHandler = reqHandler;
+ if (requestHandler != null)
+ addHandler(requestHandler);
+
+ if (specialReqHandler != null)
+ addHandler(specialReqHandler);
+
+ pivotHandler = pivHandler;
+ if (pivotHandler != null) {
+ addHandler(pivotHandler);
+ addHandler(new PivotIndicator());
+ }
+
+ if (specialRespHandler != null)
+ addHandler(specialRespHandler);
+
+ responseHandler = respHandler;
+ if (responseHandler != null)
+ addHandler(responseHandler);
+ }
+
+ public Handler getRequestHandler() { return( requestHandler ); }
+
+ public Handler getPivotHandler() { return( pivotHandler ); }
+
+ public Handler getResponseHandler() { return( responseHandler ); }
};
1.8 +1 -21 xml-axis/java/src/org/apache/axis/TargetedChain.java
Index: TargetedChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/TargetedChain.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TargetedChain.java 30 Oct 2001 16:46:34 -0000 1.7
+++ TargetedChain.java 3 Jan 2002 18:08:28 -0000 1.8
@@ -57,7 +57,7 @@
/**
* @author James Snell (jasnell@us.ibm.com)
*/
-public interface TargetedChain extends Handler {
+public interface TargetedChain extends Chain {
/**
* Returns the Request handler
@@ -65,33 +65,13 @@
public Handler getRequestHandler();
/**
- * Sets the Request Chain
- */
- public void setRequestHandler(Handler reqHandler);
-
- /**
* Returns the Pivot Handler
*/
public Handler getPivotHandler();
/**
- * Sets the Pivot Handler
- */
- public void setPivotHandler(Handler handler);
-
- /**
* Returns the Response Handler
*/
public Handler getResponseHandler();
-
- /**
- * Sets the Response Handler
- */
- public void setResponseHandler(Handler respHandler);
-
- /**
- * Clears the Handlers
- */
- public void clear();
}
1.16 +0 -3 xml-axis/java/src/org/apache/axis/deployment/v2dd/V2DDDeployableItem.java
Index: V2DDDeployableItem.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/v2dd/V2DDDeployableItem.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- V2DDDeployableItem.java 14 Nov 2001 17:26:18 -0000 1.15
+++ V2DDDeployableItem.java 3 Jan 2002 18:08:28 -0000 1.16
@@ -55,7 +55,6 @@
package org.apache.axis.deployment.v2dd;
import org.apache.axis.Handler;
-import org.apache.axis.SimpleTargetedChain;
import org.apache.axis.deployment.DeployableItem;
import org.apache.axis.deployment.DeploymentRegistry;
import org.apache.axis.deployment.DeploymentException;
@@ -99,8 +98,6 @@
// definition to configure the instance
try {
- SimpleTargetedChain stc = new SimpleTargetedChain();
-
V2DDProvider prov = service.getProvider();
String[] methods = prov.getMethods();
1.30 +23 -19 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
Index: WSDDService.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- WSDDService.java 23 Dec 2001 12:33:31 -0000 1.29
+++ WSDDService.java 3 Jan 2002 18:08:28 -0000 1.30
@@ -205,33 +205,37 @@
return cachedService;
}
- SOAPService service = new SOAPService();
- if ( getQName() != null )
- service.setName(getQName().getLocalPart());
- service.setOptions(getParametersTable());
-
- WSDDChain request = getRequestFlow();
- WSDDChain response = getResponseFlow();
-
+ Handler reqHandler = null;
+ WSDDChain request = getRequestFlow();
+
if (request != null) {
- service.setRequestHandler(request.getInstance(registry));
+ reqHandler = request.getInstance(registry);
}
-
- //service.setPivotHandler(getProvider().getInstance(registry));
+
+ Handler providerHandler = null;
+
if (providerQName != null) {
- Handler providerHandler = WSDDProvider.getInstance(providerQName,
- this,
- registry);
+ providerHandler = WSDDProvider.getInstance(providerQName,
+ this,
+ registry);
if (providerHandler == null)
throw new WSDDException(
- JavaUtils.getMessage("couldntConstructProvider00"));
-
- service.setPivotHandler(providerHandler);
+ JavaUtils.getMessage("couldntConstructProvider00"));
}
-
+
+ Handler respHandler = null;
+ WSDDChain response = getResponseFlow();
+
if (response != null) {
- service.setResponseHandler(response.getInstance(registry));
+ respHandler = response.getInstance(registry);
}
+
+ SOAPService service = new SOAPService(reqHandler, providerHandler,
+ respHandler);
+
+ if ( getQName() != null )
+ service.setName(getQName().getLocalPart());
+ service.setOptions(getParametersTable());
if (tmr == null) {
tmr = new TypeMappingRegistry();
1.4 +6 -6 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java
Index: WSDDTargetedChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTargetedChain.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WSDDTargetedChain.java 14 Nov 2001 17:26:18 -0000 1.3
+++ WSDDTargetedChain.java 3 Jan 2002 18:08:28 -0000 1.4
@@ -185,11 +185,11 @@
public Handler makeNewInstance(DeploymentRegistry registry)
throws Exception
{
- TargetedChain c = new org.apache.axis.SimpleTargetedChain();
+ Handler reqHandler = null;
WSDDChain req = getRequestFlow();
if (req != null)
- c.setRequestHandler(req.getInstance(registry));
+ reqHandler = req.getInstance(registry);
Handler pivot = null;
if (pivotQName != null) {
@@ -200,13 +200,13 @@
}
}
- c.setPivotHandler(pivot);
-
+ Handler respHandler = null;
WSDDChain resp = getResponseFlow();
if (resp != null)
- c.setResponseHandler(resp.getInstance(registry));
+ respHandler = resp.getInstance(registry);
- return c;
+ return new org.apache.axis.SimpleTargetedChain(reqHandler, pivot,
+ respHandler);
}
/**
1.41 +86 -154 xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
Index: SOAPService.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- SOAPService.java 3 Jan 2002 17:20:21 -0000 1.40
+++ SOAPService.java 3 Jan 2002 18:08:28 -0000 1.41
@@ -58,6 +58,7 @@
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
import org.apache.axis.Handler;
+import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.SimpleTargetedChain;
@@ -103,10 +104,93 @@
*/
private TypeMappingRegistry typeMap;
+ /**
+ * SOAPRequestHandler is used to inject SOAP semantics just before
+ * the pivot handler.
+ */
+ private class SOAPRequestHandler extends BasicHandler {
+ public SOAPRequestHandler() {}
+
+ public void undo(MessageContext msgContext) {}
+
+ public void invoke(MessageContext msgContext) throws AxisFault {
+ // Do SOAP semantics here
+ if (category.isDebugEnabled()) {
+ category.debug( JavaUtils.getMessage("semanticCheck00"));
+ }
+
+ // This needs to be set to the merged list of service-specific and
+ // enigne-wide actors we should be acting as.
+ ArrayList actors = msgContext.getAxisEngine().getActorURIs();
+
+ // 1. Check mustUnderstands
+ SOAPEnvelope env = msgContext.getRequestMessage().getSOAPEnvelope();
+ Vector headers = env.getHeadersByActor(actors);
+ Vector misunderstoodHeaders = null;
+ Enumeration enum = headers.elements();
+ while (enum.hasMoreElements()) {
+ SOAPHeader header = (SOAPHeader)enum.nextElement();
+ if (header.isMustUnderstand() && !header.isProcessed()) {
+ if (misunderstoodHeaders == null)
+ misunderstoodHeaders = new Vector();
+ misunderstoodHeaders.addElement(header);
+ }
+ }
+
+ // !!! we should indicate SOAP1.2 compliance via the
+ // MessageContext, not a boolean here....
+ boolean doMisunderstoodHeaders = true;
+
+ if (misunderstoodHeaders != null) {
+ // !!! If SOAP 1.2, insert misunderstood fault header here
+ if (doMisunderstoodHeaders) {
+ Message respMsg = msgContext.getResponseMessage();
+ if (respMsg == null) {
+ respMsg = new Message(new SOAPEnvelope());
+ msgContext.setResponseMessage(respMsg);
+ }
+ env = respMsg.getSOAPEnvelope();
+ enum = misunderstoodHeaders.elements();
+ while (enum.hasMoreElements()) {
+ SOAPHeader badHeader = (SOAPHeader)enum.nextElement();
+ QName badQName = new QName(badHeader.getNamespaceURI(),
+ badHeader.getName());
+ SOAPHeader newHeader = new SOAPHeader(
+ Constants.URI_SOAP12_FAULT_NS,
+ Constants.ELEM_MISUNDERSTOOD);
+ newHeader.addAttribute(null,
+ Constants.ATTR_QNAME,
+ badQName);
+
+ env.addHeader(newHeader);
+ }
+ }
+
+ throw new AxisFault(Constants.FAULT_MUSTUNDERSTAND,
+ JavaUtils.getMessage("noUnderstand00"),
+ null, null);
+ }
+ }
+ }
+
/** Standard, no-arg constructor.
*/
public SOAPService()
{
+ initTypeMappingRegistry();
+ }
+
+ /** Constructor with real or null request, pivot, and response
+ * handlers. A special request handler is specified to inject
+ * SOAP semantics.
+ */
+ public SOAPService(Handler reqHandler, Handler pivHandler,
+ Handler respHandler) {
+ init(reqHandler, new SOAPRequestHandler(), pivHandler, null, respHandler);
+ initTypeMappingRegistry();
+ }
+
+ private void initTypeMappingRegistry() {
typeMap = new TypeMappingRegistry();
typeMap.setParent(SOAPTypeMappingRegistry.getSingleton());
}
@@ -126,8 +210,8 @@
*/
public SOAPService(Handler serviceHandler)
{
- this();
- setPivotHandler(serviceHandler);
+ init(null, new SOAPRequestHandler(), serviceHandler, null, null);
+ initTypeMappingRegistry();
}
/** Tell this service which engine it's deployed to.
@@ -166,158 +250,6 @@
return true;
}
- public void invoke(MessageContext msgContext) throws AxisFault
- {
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("enter00",
- "SOAPService::invoke") );
- }
-
- if (!availableFromTransport(msgContext.getTransportName()))
- throw new AxisFault("Server.NotAvailable",
- JavaUtils.getMessage("noService02", msgContext.getTransportName()),
- null, null);
-
- msgContext.setPastPivot(false);
-
- Handler h = getRequestHandler() ;
- if ( h != null ) {
- if (category.isDebugEnabled()) {
- category.debug( JavaUtils.getMessage("invokeRequest00") );
- }
-
- h.invoke(msgContext);
- } else {
- if (category.isDebugEnabled()) {
- category.debug( JavaUtils.getMessage("noRequest01") );
- }
- }
-
- // Do SOAP semantics here
- if (category.isDebugEnabled()) {
- category.debug( JavaUtils.getMessage("semanticCheck00"));
- }
-
- // This needs to be set to the merged list of service-specific and
- // enigne-wide actors we should be acting as.
- ArrayList actors = msgContext.getAxisEngine().getActorURIs();
-
- // 1. Check mustUnderstands
- SOAPEnvelope env = msgContext.getRequestMessage().getSOAPEnvelope();
- Vector headers = env.getHeadersByActor(actors);
- Vector misunderstoodHeaders = null;
- Enumeration enum = headers.elements();
- while (enum.hasMoreElements()) {
- SOAPHeader header = (SOAPHeader)enum.nextElement();
- if (header.isMustUnderstand() && !header.isProcessed()) {
- if (misunderstoodHeaders == null)
- misunderstoodHeaders = new Vector();
- misunderstoodHeaders.addElement(header);
- }
- }
-
- // !!! we should indicate SOAP1.2 compliance via the
- // MessageContext, not a boolean here....
- boolean doMisunderstoodHeaders = true;
-
- if (misunderstoodHeaders != null) {
- // !!! If SOAP 1.2, insert misunderstood fault header here
- if (doMisunderstoodHeaders) {
- Message respMsg = msgContext.getResponseMessage();
- if (respMsg == null) {
- respMsg = new Message(new SOAPEnvelope());
- msgContext.setResponseMessage(respMsg);
- }
- env = respMsg.getSOAPEnvelope();
- enum = misunderstoodHeaders.elements();
- while (enum.hasMoreElements()) {
- SOAPHeader badHeader = (SOAPHeader)enum.nextElement();
- QName badQName = new QName(badHeader.getNamespaceURI(),
- badHeader.getName());
- SOAPHeader newHeader = new SOAPHeader(
- Constants.URI_SOAP12_FAULT_NS,
- Constants.ELEM_MISUNDERSTOOD);
- newHeader.addAttribute(null,
- Constants.ATTR_QNAME,
- badQName);
-
- env.addHeader(newHeader);
- }
- }
-
- throw new AxisFault(Constants.FAULT_MUSTUNDERSTAND,
- JavaUtils.getMessage("noUnderstand00"),
- null, null);
- }
-
- h = getPivotHandler();
- if ( h != null ) {
- if (category.isDebugEnabled()) {
- category.debug( JavaUtils.getMessage("invokeService00") );
- }
-
- h.invoke(msgContext);
- } else {
- if (category.isDebugEnabled()) {
- category.debug( JavaUtils.getMessage("noService03") );
- }
- }
-
- // OK, we're past the pivot, so let the MessageContext know.
- msgContext.setPastPivot(true);
-
- h = getResponseHandler();
- if ( h != null ) {
- if (category.isDebugEnabled()) {
- category.debug( JavaUtils.getMessage("invokeResponse00") );
- }
-
- h.invoke(msgContext);
- } else {
- if (category.isDebugEnabled()) {
- category.debug( JavaUtils.getMessage("noResponse00") );
- }
- }
-
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("exit00",
- "SOAPService::invoke") );
- }
- }
-
- public void undo(MessageContext msgContext)
- {
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("enter00",
- "SOAPService::undo") );
- category.debug(JavaUtils.getMessage("exit00",
- "SOAPService::undo") );
- }
- }
-
- public Element getDeploymentData(Document doc) {
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("enter00",
- "SOAPService::getDeploymentData") );
- }
-
- Element root = doc.createElementNS("", "service");
-
- fillInDeploymentData(root);
-
- if (!getTypeMappingRegistry().isEmpty()) {
- Element elem = doc.createElementNS("", "typeMappings");
- getTypeMappingRegistry().dumpToElement(elem);
- root.appendChild(elem);
- }
-
- if (category.isDebugEnabled()) {
- category.debug(JavaUtils.getMessage("exit00",
- "SOAPService::getDeploymentData") );
- }
- return( root );
- }
-
/*********************************************************************
* Administration and management APIs
*
1.10 +0 -10 xml-axis/java/src/org/apache/axis/server/Transport.java
Index: Transport.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/server/Transport.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Transport.java 8 Nov 2001 21:43:59 -0000 1.9
+++ Transport.java 3 Jan 2002 18:08:28 -0000 1.10
@@ -72,14 +72,4 @@
static Category category =
Category.getInstance(Transport.class.getName());
- public Element getDeploymentData(Document doc) {
- category.debug(JavaUtils.getMessage("enter00", "Transport::getDeploymentData"));
-
- Element root = doc.createElementNS("", "transport");
-
- fillInDeploymentData(root);
-
- category.debug(JavaUtils.getMessage("exit00", "Transport::getDeploymentData"));
- return( root );
- }
}
1.17 +1 -2 xml-axis/java/test/functional/TestTCPTransportSample.java
Index: TestTCPTransportSample.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/functional/TestTCPTransportSample.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TestTCPTransportSample.java 3 Dec 2001 23:23:03 -0000 1.16
+++ TestTCPTransportSample.java 3 Jan 2002 18:08:28 -0000 1.17
@@ -99,8 +99,7 @@
Service service = new Service();
Call call = (Call) service.createCall();
- SimpleTargetedChain c = new SimpleTargetedChain();
- c.setPivotHandler(new TCPSender());
+ SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
service.getEngine().deployTransport("tcp", c);
call.setTargetEndpointAddress( new URL("tcp://localhost:8088") );
1.6 +4 -3 xml-axis/java/test/session/TestSimpleSession.java
Index: TestSimpleSession.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/session/TestSimpleSession.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestSimpleSession.java 25 Nov 2001 19:11:59 -0000 1.5
+++ TestSimpleSession.java 3 Jan 2002 18:08:29 -0000 1.6
@@ -71,14 +71,15 @@
public void testSessionService() throws Exception
{
// Set up the server side
- SOAPService service = new SOAPService(new RPCProvider());
SimpleSessionHandler sessionHandler = new SimpleSessionHandler();
// Set a 3-second reap period, and a 3-second timeout
sessionHandler.setReapPeriodicity(3000);
sessionHandler.setDefaultSessionTimeout(3000);
- service.setRequestHandler(sessionHandler);
- service.setResponseHandler(sessionHandler);
+ SOAPService service = new SOAPService(sessionHandler,
+ new RPCProvider(),
+ sessionHandler);
+
service.setOption("scope", "session");
service.setOption("className", "test.session.TestSimpleSession");
service.setOption("methodName", "counter");