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 08:14:56 UTC
svn commit: r687573 - in
/servicemix/components/bindings/servicemix-http/trunk/src:
main/java/org/apache/servicemix/http/endpoints/
test/java/org/apache/servicemix/http/
Author: gertv
Date: Wed Aug 20 23:14:55 2008
New Revision: 687573
URL: http://svn.apache.org/viewvc?rev=687573&view=rev
Log:
SM-1515: Override SOAPAction header for http provider endpoint
Modified:
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java
servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java
servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java?rev=687573&r1=687572&r2=687573&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderEndpoint.java Wed Aug 20 23:14:55 2008
@@ -59,6 +59,7 @@
private boolean useJbiWrapper = true;
private boolean validateWsdl = true;
private Policy[] policies;
+ private String soapAction;
public HttpSoapProviderEndpoint() {
super();
@@ -131,6 +132,22 @@
public void setUseJbiWrapper(boolean useJbiWrapper) {
this.useJbiWrapper = useJbiWrapper;
}
+
+ /**
+ * Override the value of the SOAPAction header that is being sent
+ *
+ * @param soapAction the new value of the SOAPAction header
+ */
+ public void setSoapAction(String soapAction) {
+ this.soapAction = soapAction;
+ }
+
+ /**
+ * @return the override value for the SOAPAction header
+ */
+ public String getSoapAction() {
+ return soapAction;
+ }
public Policy[] getPolicies() {
return policies;
@@ -171,6 +188,7 @@
}
marshaler.setUseJbiWrapper(useJbiWrapper);
marshaler.setPolicies(policies);
+ marshaler.setSoapAction(soapAction);
setMarshaler(marshaler);
} catch (DeploymentException e) {
throw e;
Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java?rev=687573&r1=687572&r2=687573&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java Wed Aug 20 23:14:55 2008
@@ -32,6 +32,7 @@
import org.apache.servicemix.soap.api.Message;
import org.apache.servicemix.soap.api.Policy;
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;
@@ -49,6 +50,7 @@
private Policy[] policies;
private String baseUrl;
private Map<Phase, InterceptorChain> chains = new HashMap<Phase, InterceptorChain>();
+ private String soapAction;
public Binding<?> getBinding() {
return binding;
@@ -81,6 +83,14 @@
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,
@@ -101,6 +111,9 @@
for (Map.Entry<String,String> entry : msg.getTransportHeaders().entrySet()) {
httpExchange.addRequestHeader(entry.getKey(), entry.getValue());
}
+ if (soapAction != null) {
+ httpExchange.setRequestHeader(SoapConstants.SOAP_ACTION_HEADER, soapAction);
+ }
/*
httpExchange.setRequestEntity(new Entity() {
public void write(OutputStream os, Writer w) throws IOException {
@@ -108,7 +121,6 @@
}
});
*/
- // TODO: add transport headers
// TODO: use streaming when appropriate (?)
}
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java?rev=687573&r1=687572&r2=687573&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/java/org/apache/servicemix/http/ProviderEndpointTest.java Wed Aug 20 23:14:55 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 testSoapWithSoapAction() 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);
+ System.out.println(me);
+ }
public void testSendProblemWithoutServer() throws Exception {
HttpComponent http = new HttpComponent();