You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/06/23 15:08:58 UTC

svn commit: r416712 - in /incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http: HttpEndpoint.java processors/Constants.java processors/ConsumerProcessor.java processors/ProviderProcessor.java

Author: gnodet
Date: Fri Jun 23 06:08:58 2006
New Revision: 416712

URL: http://svn.apache.org/viewvc?rev=416712&view=rev
Log:
SM-470: ability to set the soap action on a provider endpoint
Use string constants for headers

Added:
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/Constants.java
Modified:
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
    incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java

Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java?rev=416712&r1=416711&r2=416712&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/HttpEndpoint.java Fri Jun 23 06:08:58 2006
@@ -61,7 +61,22 @@
     protected Map wsdls = new HashMap();
     protected SslParameters ssl;
     protected String authMethod;
+    protected String soapAction;
     
+    /**
+     * @return the soapAction
+     */
+    public String getSoapAction() {
+        return soapAction;
+    }
+
+    /**
+     * @param soapAction the soapAction to set
+     */
+    public void setSoapAction(String soapAction) {
+        this.soapAction = soapAction;
+    }
+
     /**
      * @return the authMethod
      */

Added: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/Constants.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/Constants.java?rev=416712&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/Constants.java (added)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/Constants.java Fri Jun 23 06:08:58 2006
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.http.processors;
+
+public interface Constants {
+
+    public static final String HEADER_SOAP_ACTION = "SOAPAction";
+    public static final String HEADER_CONTENT_TYPE = "Content-Type";
+    public static final String HEADER_CONTENT_LENGTH = "Content-Length";
+    
+}

Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=416712&r1=416711&r2=416712&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Fri Jun 23 06:08:58 2006
@@ -148,7 +148,7 @@
             try {
                 SoapMessage message = soapHelper.getSoapMarshaler().createReader().read(
                                             request.getInputStream(), 
-                                            request.getHeader("Content-Type"));
+                                            request.getHeader(Constants.HEADER_CONTENT_TYPE));
                 Context context = soapHelper.createContext(message);
                 if (request.getUserPrincipal() != null) {
                     if (request.getUserPrincipal() instanceof JaasJettyPrincipal) {

Modified: incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java?rev=416712&r1=416711&r2=416712&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java (original)
+++ incubator/servicemix/trunk/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java Fri Jun 23 06:08:58 2006
@@ -112,14 +112,18 @@
             }
         }
         RequestEntity entity = writeMessage(writer);
-        method.addRequestHeader("Content-Type", entity.getContentType());
+        method.addRequestHeader(Constants.HEADER_CONTENT_TYPE, entity.getContentType());
         if (entity.getContentLength() < 0) {
-            method.removeRequestHeader("Content-Length");
+            method.removeRequestHeader(Constants.HEADER_CONTENT_LENGTH);
         } else {
-            method.setRequestHeader("Content-Length", Long.toString(entity.getContentLength()));
+            method.setRequestHeader(Constants.HEADER_CONTENT_LENGTH, Long.toString(entity.getContentLength()));
         }
-        if (endpoint.isSoap() && method.getRequestHeader("SOAPAction") == null) {
-            method.setRequestHeader("SOAPAction", "\"\"");
+        if (endpoint.isSoap() && method.getRequestHeader(Constants.HEADER_SOAP_ACTION) == null) {
+            if (endpoint.getSoapAction() != null) {
+                method.setRequestHeader(Constants.HEADER_SOAP_ACTION, endpoint.getSoapAction());
+            } else {
+                method.setRequestHeader(Constants.HEADER_SOAP_ACTION, "\"\"");
+            }
         }
         method.setRequestEntity(entity);
         try {
@@ -127,7 +131,7 @@
             if (response != HttpStatus.SC_OK) {
                 if (exchange instanceof InOnly == false) {
                     SoapReader reader = soapHelper.getSoapMarshaler().createReader();
-                    Header contentType = method.getResponseHeader("Content-Type");
+                    Header contentType = method.getResponseHeader(Constants.HEADER_CONTENT_TYPE);
                     soapMessage = reader.read(method.getResponseBodyAsStream(), 
                                               contentType != null ? contentType.getValue() : null);
                     context.setFaultMessage(soapMessage);
@@ -145,7 +149,7 @@
             if (exchange instanceof InOut) {
                 NormalizedMessage msg = exchange.createMessage();
                 SoapReader reader = soapHelper.getSoapMarshaler().createReader();
-                Header contentType = method.getResponseHeader("Content-Type");
+                Header contentType = method.getResponseHeader(Constants.HEADER_CONTENT_TYPE);
                 soapMessage = reader.read(method.getResponseBodyAsStream(), 
                                           contentType != null ? contentType.getValue() : null);
                 context.setOutMessage(soapMessage);
@@ -162,7 +166,7 @@
                     NormalizedMessage msg = exchange.createMessage();
                     SoapReader reader = soapHelper.getSoapMarshaler().createReader();
                     soapMessage = reader.read(method.getResponseBodyAsStream(), 
-                                              method.getResponseHeader("Content-Type").getValue());
+                                              method.getResponseHeader(Constants.HEADER_CONTENT_TYPE).getValue());
                     context.setOutMessage(soapMessage);
                     soapHelper.onAnswer(context);
                     msg.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(method));