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 2008/08/29 14:49:46 UTC
svn commit: r690222 - in
/servicemix/components/bindings/servicemix-http/trunk/src:
main/java/org/apache/servicemix/http/endpoints/
test/java/org/apache/servicemix/http/ test/resources/
Author: gnodet
Date: Fri Aug 29 05:49:45 2008
New Revision: 690222
URL: http://svn.apache.org/viewvc?rev=690222&view=rev
Log:
Undo SM-1515, fix SM-1529 (make sure the SOAPAction header is correctly sent)
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
servicemix/components/bindings/servicemix-http/trunk/src/test/resources/person.wsdl
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=690222&r1=690221&r2=690222&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 Fri Aug 29 05:49:45 2008
@@ -59,7 +59,6 @@
private boolean useJbiWrapper = true;
private boolean validateWsdl = true;
private Policy[] policies;
- private String soapAction;
public HttpSoapProviderEndpoint() {
super();
@@ -133,22 +132,6 @@
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;
}
@@ -188,7 +171,6 @@
}
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=690222&r1=690221&r2=690222&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 Fri Aug 29 05:49:45 2008
@@ -50,7 +50,6 @@
private Policy[] policies;
private String baseUrl;
private Map<Phase, InterceptorChain> chains = new HashMap<Phase, InterceptorChain>();
- private String soapAction;
public Binding<?> getBinding() {
return binding;
@@ -84,15 +83,7 @@
this.policies = policies;
}
- public void setSoapAction(String soapAction) {
- this.soapAction = soapAction;
- }
-
- public String getSoapAction() {
- return soapAction;
- }
-
- public void createRequest(final MessageExchange exchange,
+ public void createRequest(final MessageExchange exchange,
final NormalizedMessage inMsg,
final SmxHttpExchange httpExchange) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -111,9 +102,6 @@
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 {
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=690222&r1=690221&r2=690222&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 Fri Aug 29 05:49:45 2008
@@ -16,8 +16,14 @@
*/
package org.apache.servicemix.http;
+import java.util.concurrent.atomic.AtomicReference;
+
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.component.ComponentContext;
import javax.xml.namespace.QName;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -31,6 +37,8 @@
import org.apache.servicemix.http.endpoints.HttpConsumerEndpoint;
import org.apache.servicemix.http.endpoints.HttpProviderEndpoint;
import org.apache.servicemix.http.endpoints.HttpSoapProviderEndpoint;
+import org.apache.servicemix.http.endpoints.HttpConsumerMarshaler;
+import org.apache.servicemix.http.endpoints.DefaultHttpConsumerMarshaler;
import org.apache.servicemix.jbi.container.JBIContainer;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.jbi.jaxp.StringSource;
@@ -108,50 +116,8 @@
}
public void testSoap() 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/");
+ final AtomicReference<String> soapAction = new AtomicReference<String>();
- 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);
-
- 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 testSoapWithSoapAction() throws Exception {
EchoComponent echo = new EchoComponent();
echo.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
echo.setEndpoint("service");
@@ -165,6 +131,12 @@
ep0.setTargetService(new QName("http://servicemix.apache.org/samples/wsdl-first", "EchoService"));
ep0.setTargetEndpoint("service");
ep0.setLocationURI("http://localhost:8192/PersonService/");
+ ep0.setMarshaler(new DefaultHttpConsumerMarshaler() {
+ public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
+ soapAction.set(request.getHeader("SOAPAction"));
+ return super.createExchange(request, context); //To change body of overridden methods use File | Settings | File Templates.
+ }
+ });
HttpSoapProviderEndpoint ep1 = new HttpSoapProviderEndpoint();
ep1.setService(new QName("http://servicemix.apache.org/samples/wsdl-first", "PersonService"));
@@ -172,7 +144,6 @@
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");
@@ -194,9 +165,10 @@
+ " </jbi:part>"
+ "</jbi:message>"));
client.sendSync(me);
- System.out.println(me);
- }
+ assertEquals("\"urn:myaction\"", soapAction.get());
+ }
+
public void testSendProblemWithoutServer() throws Exception {
HttpComponent http = new HttpComponent();
Modified: servicemix/components/bindings/servicemix-http/trunk/src/test/resources/person.wsdl
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/test/resources/person.wsdl?rev=690222&r1=690221&r2=690222&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/test/resources/person.wsdl (original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/test/resources/person.wsdl Fri Aug 29 05:49:45 2008
@@ -77,7 +77,8 @@
<wsdl:binding name="PersonSOAPBinding" type="tns:Person">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetPerson">
- <wsdl:input>
+ <soap:operation soapAction="urn:myaction" />
+ <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>