You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2008/08/21 07:31:00 UTC
svn commit: r687565 - in /servicemix/smx3/branches/servicemix-3.2:
common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/impl/
common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/
deploya...
Author: gertv
Date: Wed Aug 20 22:30:59 2008
New Revision: 687565
URL: http://svn.apache.org/viewvc?rev=687565&view=rev
Log:
SM-1460: Add support for SOAPAction on new HTTP endpoints
Added:
servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapActionOutOperationInterceptor.java
Modified:
servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/impl/Wsdl1SoapBindingImpl.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java
servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java
Modified: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/impl/Wsdl1SoapBindingImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/impl/Wsdl1SoapBindingImpl.java?rev=687565&r1=687564&r2=687565&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/impl/Wsdl1SoapBindingImpl.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/impl/Wsdl1SoapBindingImpl.java Wed Aug 20 22:30:59 2008
@@ -22,6 +22,8 @@
import org.apache.servicemix.soap.api.Message;
import org.apache.servicemix.soap.bindings.soap.SoapVersion;
import org.apache.servicemix.soap.bindings.soap.interceptors.MustUnderstandInterceptor;
+import org.apache.servicemix.soap.bindings.soap.interceptors.SoapActionInOperationInterceptor;
+import org.apache.servicemix.soap.bindings.soap.interceptors.SoapActionOutOperationInterceptor;
import org.apache.servicemix.soap.bindings.soap.interceptors.SoapFaultInInterceptor;
import org.apache.servicemix.soap.bindings.soap.interceptors.SoapFaultOutInterceptor;
import org.apache.servicemix.soap.bindings.soap.interceptors.SoapInInterceptor;
@@ -63,6 +65,7 @@
phase.add(new AttachmentsInInterceptor());
phase.add(new StaxInInterceptor());
phase.add(new SoapInInterceptor(soapVersion));
+ phase.add(new SoapActionInOperationInterceptor());
phase.add(new WsdlOperationInInterceptor());
phase.add(new MustUnderstandInterceptor());
phase.add(new JbiInWsdl1Interceptor(true));
@@ -88,6 +91,7 @@
phase = getInterceptors(Phase.ClientOut);
phase.add(new JbiOutInterceptor(false));
phase.add(new JbiOutWsdl1Interceptor(false));
+ phase.add(new SoapActionOutOperationInterceptor());
phase.add(new AttachmentsOutInterceptor());
phase.add(new StaxOutInterceptor());
phase.add(new SoapOutInterceptor(soapVersion));
Added: servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapActionOutOperationInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapActionOutOperationInterceptor.java?rev=687565&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapActionOutOperationInterceptor.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-soap2/src/main/java/org/apache/servicemix/soap/bindings/soap/interceptors/SoapActionOutOperationInterceptor.java Wed Aug 20 22:30:59 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.servicemix.soap.bindings.soap.interceptors;
+
+import org.apache.servicemix.soap.core.AbstractInterceptor;
+import org.apache.servicemix.soap.api.Message;
+import org.apache.servicemix.soap.api.model.Operation;
+import org.apache.servicemix.soap.bindings.soap.model.SoapOperation;
+import org.apache.servicemix.soap.bindings.soap.SoapConstants;
+
+public class SoapActionOutOperationInterceptor extends AbstractInterceptor {
+
+ public void handleMessage(Message message) {
+ Operation operation = message.get(Operation.class);
+ if (!(operation instanceof SoapOperation)) {
+ return;
+ }
+ SoapOperation soapOp = (SoapOperation) operation;
+ if (soapOp.getSoapAction() != null) {
+ message.getTransportHeaders().put(SoapConstants.SOAP_ACTION_HEADER, soapOp.getSoapAction());
+ }
+ }
+
+}
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java?rev=687565&r1=687564&r2=687565&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java Wed Aug 20 22:30:59 2008
@@ -57,6 +57,7 @@
private boolean useJbiWrapper = true;
private boolean validateWsdl = true;
private Policy[] policies;
+ private String soapAction;
public HttpSoapProviderEndpoint() {
super();
@@ -102,6 +103,13 @@
this.policies = policies;
}
+ public void setSoapAction(String soapAction) {
+ this.soapAction = soapAction;
+ }
+
+ public String getSoapAction() {
+ return soapAction;
+ }
@Override
public void validate() throws DeploymentException {
@@ -128,6 +136,7 @@
}
marshaler.setUseJbiWrapper(useJbiWrapper);
marshaler.setPolicies(policies);
+ marshaler.setSoapAction(soapAction);
setMarshaler(marshaler);
} catch (DeploymentException e) {
throw e;
@@ -217,4 +226,5 @@
marshaler.setBinding(BindingFactory.createBinding(endpoint));
}
+
}
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java?rev=687565&r1=687564&r2=687565&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java Wed Aug 20 22:30:59 2008
@@ -26,10 +26,11 @@
import org.apache.servicemix.http.jetty.SmxHttpExchange;
import org.apache.servicemix.soap.api.InterceptorChain;
-import org.apache.servicemix.soap.api.InterceptorProvider.Phase;
import org.apache.servicemix.soap.api.Message;
import org.apache.servicemix.soap.api.Policy;
+import org.apache.servicemix.soap.api.InterceptorProvider.Phase;
import org.apache.servicemix.soap.api.model.Binding;
+import org.apache.servicemix.soap.bindings.soap.SoapConstants;
import org.apache.servicemix.soap.interceptors.jbi.JbiConstants;
import org.apache.servicemix.soap.interceptors.xml.StaxInInterceptor;
import org.mortbay.io.ByteArrayBuffer;
@@ -46,6 +47,7 @@
private boolean useJbiWrapper = true;
private Policy[] policies;
private String baseUrl;
+ private String soapAction;
public Binding<?> getBinding() {
return binding;
@@ -78,7 +80,15 @@
public void setPolicies(Policy[] policies) {
this.policies = policies;
}
-
+
+ public void setSoapAction(String soapAction) {
+ this.soapAction = soapAction;
+ }
+
+ public String getSoapAction() {
+ return soapAction;
+ }
+
public void createRequest(final MessageExchange exchange,
final NormalizedMessage inMsg,
final SmxHttpExchange httpExchange) throws Exception {
@@ -95,14 +105,20 @@
httpExchange.setMethod(HttpMethods.POST);
httpExchange.setURL(baseUrl);
httpExchange.setRequestContent(new ByteArrayBuffer(baos.toByteArray()));
+
+ for (String header : msg.getTransportHeaders().keySet()) {
+ httpExchange.setRequestHeader(header, msg.getTransportHeaders().get(header));
+ }
+ if (soapAction != null) {
+ httpExchange.setRequestHeader(SoapConstants.SOAP_ACTION_HEADER, soapAction);
+ }
/*
httpExchange.setRequestEntity(new Entity() {
public void write(OutputStream os, Writer w) throws IOException {
// TODO: handle http headers: Content-Type, ...
}
});
- */
- // TODO: add transport headers
+ */
// TODO: use streaming when appropriate (?)
}
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java?rev=687565&r1=687564&r2=687565&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java Wed Aug 20 22:30:59 2008
@@ -97,7 +97,7 @@
public void testSoap() throws Exception {
EchoComponent echo = new EchoComponent();
- echo.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
+ echo.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
echo.setEndpoint("service");
container.activateComponent(echo, "echo");
@@ -106,7 +106,7 @@
HttpConsumerEndpoint ep0 = new HttpConsumerEndpoint();
ep0.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
ep0.setEndpoint("consumer");
- ep0.setTargetService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
+ ep0.setTargetService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
ep0.setTargetEndpoint("service");
ep0.setLocationURI("http://localhost:8192/PersonService/");
@@ -138,6 +138,52 @@
+ "</jbi:message>"));
client.sendSync(me);
}
+
+ public void testSoapWithActionHeader() throws Exception {
+ EchoComponent echo = new EchoComponent();
+ echo.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
+ echo.setEndpoint("service");
+ container.activateComponent(echo, "echo");
+
+ HttpComponent http = new HttpComponent();
+
+ HttpConsumerEndpoint ep0 = new HttpConsumerEndpoint();
+ ep0.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
+ ep0.setEndpoint("consumer");
+ ep0.setTargetService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
+ ep0.setTargetEndpoint("service");
+ ep0.setLocationURI("http://localhost:8192/PersonService/");
+
+ HttpSoapProviderEndpoint ep1 = new HttpSoapProviderEndpoint();
+ ep1.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
+ ep1.setEndpoint("soap");
+ ep1.setWsdl(new ClassPathResource("person.wsdl"));
+ ep1.setValidateWsdl(false); // TODO: Soap 1.2 not handled yet
+ ep1.setUseJbiWrapper(true);
+ ep1.setSoapAction("http://servicemix.apache.org/samples/wsdl-first/PersonService/GetPerson");
+
+ http.setEndpoints(new HttpEndpointType[] {ep0, ep1 });
+ container.activateComponent(http, "http");
+
+ container.start();
+
+ ServiceMixClient client = new DefaultServiceMixClient(container);
+ InOut me = client.createInOutExchange();
+ me.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
+ me.setOperation(new QName("http://servicemix.apache.org/samples/wsdl-first", "GetPerson"));
+ me.getInMessage().setContent(new StringSource(
+ "<jbi:message xmlns:jbi=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\""
+ + " xmlns:msg=\"http://servicemix.apache.org/samples/wsdl-first/types\" "
+ + " name=\"Hello\" "
+ + " type=\"msg:HelloRequest\" "
+ + " version=\"1.0\">"
+ + " <jbi:part>"
+ + " <msg:GetPerson><msg:personId>id</msg:personId></msg:GetPerson>"
+ + " </jbi:part>"
+ + "</jbi:message>"));
+ client.sendSync(me);
+ }
+
public void testSendProblem() throws Exception {
HttpComponent http = new HttpComponent();