axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r557675 - in /webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj: SOAPConnectionImpl.java util/UnderstandAllHeadersHandler.java
Date Thu, 19 Jul 2007 16:25:19 GMT
Author: gawor
Date: Thu Jul 19 09:25:17 2007
New Revision: 557675

URL: http://svn.apache.org/viewvc?view=rev&rev=557675
Log:
MU processing should not be done for SAAJ clients

Added:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/UnderstandAllHeadersHandler.java
  (with props)
Modified:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java?view=diff&rev=557675&r1=557674&r2=557675
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
Thu Jul 19 09:25:17 2007
@@ -30,8 +30,11 @@
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.DispatchPhase;
 import org.apache.axis2.saaj.util.IDGenerator;
 import org.apache.axis2.saaj.util.SAAJUtil;
+import org.apache.axis2.saaj.util.UnderstandAllHeadersHandler;
 import org.apache.axis2.wsdl.WSDLConstants;
 
 import javax.activation.DataHandler;
@@ -55,6 +58,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -105,7 +109,8 @@
         // initialize the Sender
         OperationClient opClient;
         try {
-            serviceClient = new ServiceClient();
+            serviceClient = new ServiceClient();   
+            disableMustUnderstandProcessing(serviceClient.getAxisConfiguration());      
     
             opClient = serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
         } catch (AxisFault e) {
             throw new SOAPException(e);
@@ -121,6 +126,33 @@
         }
     }
 
+    /*
+     * Installs UnderstandAllHeadersHandler that marks all headers as processed 
+     * because MU validation should not be done for SAAJ clients.
+     */
+    private void disableMustUnderstandProcessing(AxisConfiguration config) {
+        DispatchPhase phase;
+        phase = getDispatchPhase(serviceClient.getAxisConfiguration().getInFlowPhases());
+        if (phase != null) {
+            phase.addHandler(new UnderstandAllHeadersHandler());
+        }
+        phase = getDispatchPhase(serviceClient.getAxisConfiguration().getInFaultFlowPhases());
+        if (phase != null) {
+            phase.addHandler(new UnderstandAllHeadersHandler());
+        }
+    }
+    
+    private static DispatchPhase getDispatchPhase(List phases) {
+        Iterator iter = phases.iterator();
+        while(iter.hasNext()) {
+            Object phase = iter.next();
+            if (phase instanceof DispatchPhase) {
+                return (DispatchPhase)phase;
+            }
+        }
+        return null;        
+    }
+    
     /**
      * Closes this <CODE>SOAPConnection</CODE> object.
      *

Added: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/UnderstandAllHeadersHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/UnderstandAllHeadersHandler.java?view=auto&rev=557675
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/UnderstandAllHeadersHandler.java
(added)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/UnderstandAllHeadersHandler.java
Thu Jul 19 09:25:17 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.saaj.util;
+
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+
+/**
+ * Marks all SOAP headers as processed.
+ */
+public class UnderstandAllHeadersHandler extends AbstractHandler {
+
+    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+        if (msgContext == null) {
+            return InvocationResponse.CONTINUE;
+        } 
+                
+        SOAPEnvelope envelope = msgContext.getEnvelope();
+        if (envelope.getHeader() == null) {
+            return InvocationResponse.CONTINUE;          
+        }
+        
+        // Passing in null will get headers targeted for NEXT and ULTIMATE RECEIVER
+        Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(null);
+        while (headerBlocks.hasNext()) {
+            SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
+            headerBlock.setProcessed();            
+        }
+        return InvocationResponse.CONTINUE;        
+    }
+  
+}

Propchange: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/UnderstandAllHeadersHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message