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 2007/03/08 18:22:26 UTC
svn commit: r516106 - in
/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src:
main/java/org/apache/servicemix/http/endpoints/
main/java/org/apache/servicemix/http/processors/
test/java/org/apache/servicemix/http/ test/java/org...
Author: gnodet
Date: Thu Mar 8 09:22:25 2007
New Revision: 516106
URL: http://svn.apache.org/viewvc?view=rev&rev=516106
Log:
SM-537: new endpoints on servicemix-http
Added:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java (with props)
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java (with props)
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java (with props)
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl (with props)
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl (with props)
Modified:
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/DefaultHttpConsumerMarshaler.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/DefaultHttpConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/DefaultHttpConsumerMarshaler.java?view=diff&rev=516106&r1=516105&r2=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/DefaultHttpConsumerMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/DefaultHttpConsumerMarshaler.java Thu Mar 8 09:22:25 2007
@@ -16,6 +16,8 @@
*/
package org.apache.servicemix.http.endpoints;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.net.URI;
import javax.jbi.component.ComponentContext;
@@ -24,14 +26,33 @@
import javax.jbi.messaging.NormalizedMessage;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.stream.StreamSource;
-import org.apache.servicemix.jbi.FaultException;
+import org.apache.servicemix.jbi.jaxp.StAXSourceTransformer;
+import org.apache.servicemix.jbi.jaxp.XMLStreamHelper;
import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
+/**
+ * The default consumer marshaler used for non-soap consumer endpoints.
+ *
+ * @author gnodet
+ * @since 3.2
+ */
public class DefaultHttpConsumerMarshaler implements HttpConsumerMarshaler {
- private URI defaultMep = MessageExchangeSupport.IN_OUT;
+ private StAXSourceTransformer transformer = new StAXSourceTransformer();
+ private URI defaultMep;
+ public DefaultHttpConsumerMarshaler() {
+ this(MessageExchangeSupport.IN_OUT);
+ }
+
+ public DefaultHttpConsumerMarshaler(URI defaultMep) {
+ this.defaultMep = defaultMep;
+ }
+
public URI getDefaultMep() {
return defaultMep;
}
@@ -44,21 +65,40 @@
MessageExchange me;
me = context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());
NormalizedMessage in = me.createMessage();
+ in.setContent(new StreamSource(request.getInputStream()));
me.setMessage(in, "in");
return me;
}
public void sendOut(MessageExchange exchange, NormalizedMessage outMsg, HttpServletRequest request, HttpServletResponse response) throws Exception {
- // TODO Auto-generated method stub
-
+ XMLStreamReader reader = transformer.toXMLStreamReader(outMsg.getContent());
+ XMLStreamWriter writer = transformer.getOutputFactory().createXMLStreamWriter(response.getWriter());
+ writer.writeStartDocument();
+ XMLStreamHelper.copy(reader, writer);
+ writer.writeEndDocument();
+ writer.flush();
+ response.setStatus(HttpServletResponse.SC_OK);
}
public void sendFault(MessageExchange exchange, Fault fault, HttpServletRequest request, HttpServletResponse response) throws Exception {
- throw new FaultException("Fault occured", exchange, fault);
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ XMLStreamReader reader = transformer.toXMLStreamReader(fault.getContent());
+ XMLStreamWriter writer = transformer.getOutputFactory().createXMLStreamWriter(response.getWriter());
+ XMLStreamHelper.copy(reader, writer);
}
public void sendError(MessageExchange exchange, Exception error, HttpServletRequest request, HttpServletResponse response) throws Exception {
- throw error;
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ XMLStreamWriter writer = transformer.getOutputFactory().createXMLStreamWriter(response.getWriter());
+ writer.writeStartDocument();
+ writer.writeStartElement("error");
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ error.printStackTrace(pw);
+ pw.close();
+ writer.writeCData(sw.toString());
+ writer.writeEndElement();
+ writer.writeEndDocument();
}
public void sendAccepted(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response) throws Exception {
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java?view=diff&rev=516106&r1=516105&r2=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerEndpoint.java Thu Mar 8 09:22:25 2007
@@ -53,8 +53,13 @@
import org.w3c.dom.Node;
/**
+ * Plain HTTP consumer endpoint.
+ * This endpoint can be used to handle plain HTTP request (without SOAP) or
+ * to be able to process the request in a non standard way. For HTTP requests,
+ * a WSDL2 HTTP binding can be used.
*
* @author gnodet
+ * @since 3.2
* @org.apache.xbean.XBean element="consumer"
*/
public class HttpConsumerEndpoint extends ConsumerEndpoint implements ExchangeProcessor, HttpProcessor, HttpEndpointType {
@@ -267,6 +272,7 @@
} catch (Exception e) {
exchange.setError(e);
send(exchange);
+ throw e;
}
} else if (exchange.getStatus() == ExchangeStatus.DONE) {
// This happens when there is no response to send back
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java?view=diff&rev=516106&r1=516105&r2=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpConsumerMarshaler.java Thu Mar 8 09:22:25 2007
@@ -23,6 +23,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+/**
+ *
+ * @author gnodet
+ * @since 3.2
+ */
public interface HttpConsumerMarshaler {
MessageExchange createExchange(HttpServletRequest request,
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java?view=auto&rev=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java Thu Mar 8 09:22:25 2007
@@ -0,0 +1,204 @@
+/*
+ * 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.http.endpoints;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.servicedesc.ServiceEndpoint;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.common.DefaultComponent;
+import org.apache.servicemix.common.ServiceUnit;
+import org.apache.servicemix.soap.api.Policy;
+import org.apache.servicemix.soap.util.DomUtil;
+import org.apache.servicemix.soap.wsdl.BindingFactory;
+import org.apache.servicemix.soap.wsdl.WSDLUtils;
+import org.apache.servicemix.soap.wsdl.validator.WSIBPValidator;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.springframework.core.io.Resource;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author gnodet
+ * @since 3.2
+ * @org.apache.xbean.XBean element="soap-consumer"
+ */
+public class HttpSoapConsumerEndpoint extends HttpConsumerEndpoint {
+
+ private Resource wsdl;
+ private boolean useJbiWrapper = true;
+ private boolean validateWsdl = true;
+ private Policy[] policies;
+
+ public HttpSoapConsumerEndpoint() {
+ super();
+ }
+
+ public HttpSoapConsumerEndpoint(DefaultComponent component, ServiceEndpoint endpoint) {
+ super(component, endpoint);
+ }
+
+ public HttpSoapConsumerEndpoint(ServiceUnit serviceUnit, QName service, String endpoint) {
+ super(serviceUnit, service, endpoint);
+ }
+
+ public Resource getWsdl() {
+ return wsdl;
+ }
+
+ public void setWsdl(Resource wsdl) {
+ this.wsdl = wsdl;
+ }
+
+ public boolean isValidateWsdl() {
+ return validateWsdl;
+ }
+
+ public void setValidateWsdl(boolean validateWsdl) {
+ this.validateWsdl = validateWsdl;
+ }
+
+ public boolean isUseJbiWrapper() {
+ return useJbiWrapper;
+ }
+
+ public void setUseJbiWrapper(boolean useJbiWrapper) {
+ this.useJbiWrapper = useJbiWrapper;
+ }
+
+ public Policy[] getPolicies() {
+ return policies;
+ }
+
+ public void setPolicies(Policy[] policies) {
+ this.policies = policies;
+ }
+
+ @Override
+ public void validate() throws DeploymentException {
+ if (wsdl == null) {
+ throw new DeploymentException("wsdl property must be set");
+ }
+ HttpSoapConsumerMarshaler marshaler = new HttpSoapConsumerMarshaler();
+ try {
+ description = DomUtil.parse(wsdl.getInputStream());
+ Element elem = description.getDocumentElement();
+ if (WSDLUtils.WSDL1_NAMESPACE.equals(elem.getNamespaceURI())) {
+ Definition def = WSDLUtils.createWSDL11Reader().readWSDL(wsdl.getURL().toString());
+ if (validateWsdl) {
+ WSIBPValidator validator = new WSIBPValidator(def);
+ if (!validator.isValid()) {
+ throw new DeploymentException("WSDL is not WS-I BP compliant: " + validator.getErrors());
+ }
+ }
+ Service svc;
+ if (getService() != null) {
+ svc = def.getService(getService());
+ if (svc == null) {
+ throw new DeploymentException("Could not find service '" + getService() + "' in wsdl");
+ }
+ } else if (def.getServices().size() == 1) {
+ svc = (Service) def.getServices().values().iterator().next();
+ setService(svc.getQName());
+ } else {
+ throw new DeploymentException("If service is not set, the WSDL must contain a single service definition");
+ }
+ Port port;
+ if (getEndpoint() != null) {
+ port = svc.getPort(getEndpoint());
+ if (port == null) {
+ throw new DeploymentException("Cound not find port '" + getEndpoint() + "' in wsdl for service '" + getService() + "'");
+ }
+ } else if (svc.getPorts().size() == 1) {
+ port = (Port) svc.getPorts().values().iterator().next();
+ setEndpoint(port.getName());
+ } else {
+ throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService() + "' must contain a single port definition");
+ }
+ SOAPAddress soapAddress = WSDLUtils.getExtension(port, SOAPAddress.class);
+ if (soapAddress != null) {
+ soapAddress.setLocationURI(getLocationURI());
+ } else {
+ SOAP12Address soap12Address = WSDLUtils.getExtension(port, SOAP12Address.class);
+ if (soap12Address != null) {
+ soap12Address.setLocationURI(getLocationURI());
+ }
+ }
+ description = WSDLUtils.getWSDL11Factory().newWSDLWriter().getDocument(def);
+ marshaler.setBinding(BindingFactory.createBinding(port));
+ } else if (WSDLUtils.WSDL2_NAMESPACE.equals(elem.getNamespaceURI())) {
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ DescriptionElement descElement = reader.readWSDL(wsdl.getURL().toString());
+ Description desc = descElement.toComponent();
+ org.apache.woden.wsdl20.Service svc;
+ if (getService() != null) {
+ svc = desc.getService(getService());
+ if (svc == null) {
+ throw new DeploymentException("Could not find service '" + getService() + "' in wsdl");
+ }
+ } else if (desc.getServices().length == 1) {
+ svc = desc.getServices()[0];
+ setService(svc.getName());
+ } else {
+ throw new DeploymentException("If service is not set, the WSDL must contain a single service definition");
+ }
+ Endpoint endpoint;
+ if (getEndpoint() != null) {
+ endpoint = svc.getEndpoint(new NCName(getEndpoint()));
+ if (endpoint == null) {
+ throw new DeploymentException("Cound not find endpoint '" + getEndpoint() + "' in wsdl for service '" + getService() + "'");
+ }
+ } else if (svc.getEndpoints().length == 1) {
+ endpoint = svc.getEndpoints()[0];
+ setEndpoint(endpoint.getName().toString());
+ } else {
+ throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService() + "' must contain a single port definition");
+ }
+ marshaler.setBinding(BindingFactory.createBinding(endpoint));
+ } else {
+ throw new DeploymentException("Unrecognized wsdl namespace: " + elem.getNamespaceURI());
+ }
+ marshaler.setUseJbiWrapper(useJbiWrapper);
+ marshaler.setPolicies(policies);
+ setMarshaler(marshaler);
+ } catch (DeploymentException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeploymentException("Unable to read WSDL from: " + wsdl, e);
+ }
+ if (getTargetService() == null && getTargetInterface() == null && getTargetUri() == null) {
+ setTargetService(getService());
+ setTargetEndpoint(getEndpoint());
+ }
+ super.validate();
+ }
+
+ protected void loadStaticResources() {
+ addResource(MAIN_WSDL, description);
+ }
+
+}
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java?view=auto&rev=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java Thu Mar 8 09:22:25 2007
@@ -0,0 +1,166 @@
+/*
+ * 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.http.endpoints;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.jbi.component.ComponentContext;
+import javax.jbi.messaging.Fault;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.soap.api.InterceptorChain;
+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.http.HttpConstants;
+import org.apache.servicemix.soap.bindings.soap.SoapFault;
+import org.apache.servicemix.soap.bindings.soap.SoapVersion;
+import org.apache.servicemix.soap.interceptors.jbi.JbiConstants;
+
+/**
+ *
+ * @author gnodet
+ * @since 3.2
+ */
+public class HttpSoapConsumerMarshaler implements HttpConsumerMarshaler {
+
+ private Binding<?> binding;
+ private boolean useJbiWrapper = true;
+ private Policy[] policies;
+
+ public Binding<?> getBinding() {
+ return binding;
+ }
+
+ public void setBinding(Binding<?> binding) {
+ this.binding = binding;
+ }
+
+ public boolean isUseJbiWrapper() {
+ return useJbiWrapper;
+ }
+
+ public void setUseJbiWrapper(boolean useJbiWrapper) {
+ this.useJbiWrapper = useJbiWrapper;
+ }
+
+ public Policy[] getPolicies() {
+ return policies;
+ }
+
+ public void setPolicies(Policy[] policies) {
+ this.policies = policies;
+ }
+
+ public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
+ String method = request.getMethod();
+ Message msg = binding.createMessage();
+ msg.put(ComponentContext.class, context);
+ msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
+ msg.put(Message.CONTENT_TYPE, request.getContentType());
+ Map<String, String> headers = msg.getTransportHeaders();
+ for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) {
+ String name = (String) e.nextElement();
+ String value = request.getHeader(name);
+ headers.put(name, value);
+ }
+ headers.put(HttpConstants.REQUEST_URI, request.getRequestURL().toString());
+ headers.put(HttpConstants.CONTENT_TYPE, request.getContentType());
+ headers.put(HttpConstants.REQUEST_METHOD, method);
+ if (HttpConstants.METHOD_POST.equals(method) || HttpConstants.METHOD_PUT.equals(method)) {
+ msg.setContent(InputStream.class, request.getInputStream());
+ }
+ request.setAttribute(Message.class.getName(), msg);
+ InterceptorChain phase = getChain(Phase.ServerIn);
+ phase.doIntercept(msg);
+ MessageExchange me = msg.getContent(MessageExchange.class);
+ return me;
+ }
+
+ public void sendAccepted(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ }
+
+ public void sendOut(MessageExchange exchange, NormalizedMessage outMsg, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ Message in = (Message) request.getAttribute(Message.class.getName());
+ Message msg = binding.createMessage(in);
+ msg.setContent(OutputStream.class, response.getOutputStream());
+ msg.setContent(MessageExchange.class, exchange);
+ msg.setContent(NormalizedMessage.class, outMsg);
+ msg.put(SoapVersion.class, in.get(SoapVersion.class));
+ msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
+ InterceptorChain phase = getChain(Phase.ServerOut);
+ phase.doIntercept(msg);
+ // TODO: handle http headers: Content-Type, ...
+ }
+
+ public void sendError(MessageExchange exchange, Exception error, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ Message in = (Message) request.getAttribute(Message.class.getName());
+ Message msg = binding.createMessage(in);
+ msg.setContent(OutputStream.class, response.getOutputStream());
+ msg.setContent(MessageExchange.class, exchange);
+ msg.put(SoapVersion.class, in.get(SoapVersion.class));
+ msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
+ InterceptorChain phase = getChain(Phase.ServerOutFault);
+ SoapFault soapFault;
+ if (error instanceof SoapFault) {
+ soapFault = (SoapFault) error;
+ } else {
+ soapFault = new SoapFault(error);
+ }
+ msg.setContent(Exception.class, soapFault);
+ phase.doIntercept(msg);
+ }
+
+ public void sendFault(MessageExchange exchange, Fault fault, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ Message in = (Message) request.getAttribute(Message.class.getName());
+ Message msg = binding.createMessage(in);
+ msg.setContent(OutputStream.class, response.getOutputStream());
+ msg.setContent(MessageExchange.class, exchange);
+ msg.setContent(NormalizedMessage.class, fault);
+ msg.put(SoapVersion.class, in.get(SoapVersion.class));
+ msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
+ InterceptorChain phase = getChain(Phase.ServerOutFault);
+ QName code = (QName) fault.getProperty("org.apache.servicemix.soap.fault.code");
+ String reason = (String) fault.getProperty("org.apache.servicemix.soap.fault.reason");
+ SoapFault soapFault = new SoapFault(code, reason, null, null, fault.getContent());
+ msg.setContent(Exception.class, soapFault);
+ phase.doIntercept(msg);
+ // TODO: handle http headers: Content-Type, ...
+ }
+
+ protected InterceptorChain getChain(Phase phase) {
+ InterceptorChain chain = binding.getInterceptorChain(phase);
+ if (policies != null) {
+ for (int i = 0; i < policies.length; i++) {
+ chain.add(policies[i].getInterceptors(phase));
+ }
+ }
+ return chain;
+ }
+
+}
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?view=diff&rev=516106&r1=516105&r2=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Thu Mar 8 09:22:25 2007
@@ -30,6 +30,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
@@ -51,6 +52,7 @@
import org.apache.servicemix.soap.marshalers.JBIMarshaler;
import org.apache.servicemix.soap.marshalers.SoapMessage;
import org.apache.servicemix.soap.marshalers.SoapWriter;
+import org.mortbay.jetty.RetryRequest;
import org.mortbay.util.ajax.Continuation;
import org.mortbay.util.ajax.ContinuationSupport;
import org.w3c.dom.Node;
@@ -192,7 +194,13 @@
}
request.removeAttribute(MessageExchange.class.getName());
}
+ } catch (RetryRequest retry) {
+ throw retry;
} catch (SoapFault fault) {
+ sendFault(fault, request, response);
+ return;
+ } catch (Exception e) {
+ SoapFault fault = new SoapFault(e);
sendFault(fault, request, response);
return;
}
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java?view=auto&rev=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java Thu Mar 8 09:22:25 2007
@@ -0,0 +1,395 @@
+/*
+ * 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.http;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
+import javax.xml.transform.TransformerException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.Destination;
+import org.apache.servicemix.components.http.InvalidStatusResponseException;
+import org.apache.servicemix.components.util.EchoComponent;
+import org.apache.servicemix.components.util.MockServiceComponent;
+import org.apache.servicemix.components.util.TransformComponentSupport;
+import org.apache.servicemix.http.endpoints.DefaultHttpConsumerMarshaler;
+import org.apache.servicemix.http.endpoints.HttpConsumerEndpoint;
+import org.apache.servicemix.http.endpoints.HttpSoapConsumerEndpoint;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.messaging.MessageExchangeSupport;
+import org.apache.servicemix.jbi.util.ByteArrayDataSource;
+import org.apache.servicemix.jbi.util.DOMUtil;
+import org.apache.servicemix.jbi.util.FileUtil;
+import org.apache.servicemix.soap.bindings.soap.Soap11;
+import org.apache.servicemix.soap.bindings.soap.Soap12;
+import org.apache.servicemix.soap.bindings.soap.SoapConstants;
+import org.apache.servicemix.soap.interceptors.jbi.JbiConstants;
+import org.apache.servicemix.soap.util.DomUtil;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.apache.xpath.CachedXPathAPI;
+import org.springframework.core.io.ClassPathResource;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.traversal.NodeIterator;
+
+public class ConsumerEndpointTest extends TestCase {
+
+ protected JBIContainer container;
+ protected SourceTransformer transformer = new SourceTransformer();
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setEmbedded(true);
+ container.init();
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ protected String textValueOfXPath(Node node, String xpath) throws TransformerException {
+ CachedXPathAPI cachedXPathAPI = new CachedXPathAPI();
+ NodeIterator iterator = cachedXPathAPI.selectNodeIterator(node, xpath);
+ Node root = iterator.nextNode();
+ if (root instanceof Element) {
+ Element element = (Element) root;
+ if (element == null) {
+ return "";
+ }
+ String text = DOMUtil.getElementText(element);
+ return text;
+ }
+ else if (root != null) {
+ return root.getNodeValue();
+ } else {
+ return null;
+ }
+ }
+
+ public void testHttpInOnly() throws Exception {
+ HttpComponent http = new HttpComponent();
+ HttpConsumerEndpoint ep = new HttpConsumerEndpoint();
+ ep.setService(new QName("urn:test", "svc"));
+ ep.setEndpoint("ep");
+ ep.setTargetService(new QName("urn:test", "recv"));
+ ep.setLocationURI("http://localhost:8192/ep1/");
+ ep.setDefaultMep(MessageExchangeSupport.IN_ONLY);
+ http.setEndpoints(new HttpEndpointType[] { ep });
+ container.activateComponent(http, "http");
+
+ ReceiverComponent recv = new ReceiverComponent();
+ recv.setService(new QName("urn:test", "recv"));
+ container.activateComponent(recv, "recv");
+
+ container.start();
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep1/");
+ post.setRequestEntity(new StringRequestEntity("<hello>world</hello>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ assertEquals("", res);
+ if (post.getStatusCode() != 202) {
+ throw new InvalidStatusResponseException(post.getStatusCode());
+ }
+
+ recv.getMessageList().assertMessagesReceived(1);
+ }
+
+ public void testHttpInOut() throws Exception {
+ HttpComponent http = new HttpComponent();
+ HttpConsumerEndpoint ep = new HttpConsumerEndpoint();
+ ep.setService(new QName("urn:test", "svc"));
+ ep.setEndpoint("ep");
+ ep.setTargetService(new QName("urn:test", "echo"));
+ ep.setLocationURI("http://localhost:8192/ep1/");
+ http.setEndpoints(new HttpEndpointType[] { ep });
+ container.activateComponent(http, "http");
+
+ EchoComponent echo = new EchoComponent();
+ echo.setService(new QName("urn:test", "echo"));
+ echo.setEndpoint("endpoint");
+ container.activateComponent(echo, "echo");
+
+ container.start();
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep1/");
+ post.setRequestEntity(new StringRequestEntity("<hello>world</hello>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ Node node = transformer.toDOMNode(new StringSource(res));
+ System.err.println(transformer.toString(node));
+ assertEquals("world", textValueOfXPath(node, "/hello/text()"));
+ if (post.getStatusCode() != 200) {
+ throw new InvalidStatusResponseException(post.getStatusCode());
+ }
+ }
+
+ protected void initSoapEndpoints(boolean useJbiWrapper) throws Exception {
+ HttpComponent http = new HttpComponent();
+ HttpSoapConsumerEndpoint ep1 = new HttpSoapConsumerEndpoint();
+ ep1.setService(new QName("uri:HelloWorld", "HelloService"));
+ ep1.setEndpoint("HelloPortSoap11");
+ ep1.setTargetService(new QName("urn:test", "echo"));
+ ep1.setLocationURI("http://localhost:8192/ep1/");
+ ep1.setWsdl(new ClassPathResource("/org/apache/servicemix/http/HelloWorld-DOC.wsdl"));
+ ep1.setValidateWsdl(false); // TODO: Soap 1.2 not handled yet
+ ep1.setUseJbiWrapper(useJbiWrapper);
+ HttpSoapConsumerEndpoint ep2 = new HttpSoapConsumerEndpoint();
+ ep2.setService(new QName("uri:HelloWorld", "HelloService"));
+ ep2.setEndpoint("HelloPortSoap12");
+ ep2.setTargetService(new QName("urn:test", "echo"));
+ ep2.setLocationURI("http://localhost:8192/ep2/");
+ ep2.setWsdl(new ClassPathResource("/org/apache/servicemix/http/HelloWorld-DOC.wsdl"));
+ ep2.setValidateWsdl(false); // TODO: Soap 1.2 not handled yet
+ ep2.setUseJbiWrapper(useJbiWrapper);
+ http.setEndpoints(new HttpEndpointType[] { ep1, ep2 });
+ container.activateComponent(http, "http");
+ container.start();
+ }
+
+ public void testHttpSoap11FaultOnEnvelope() throws Exception {
+ initSoapEndpoints(true);
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep1/");
+ post.setRequestEntity(new StringRequestEntity("<hello>world</hello>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ Element elem = transformer.toDOMElement(new StringSource(res));
+ assertEquals(Soap11.getInstance().getEnvelope(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap11.getInstance().getBody(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap11.getInstance().getFault(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(SoapConstants.SOAP_11_FAULTCODE, DomUtil.getQName(elem));
+ assertEquals(SoapConstants.SOAP_11_CODE_VERSIONMISMATCH, DomUtil.createQName(elem, elem.getTextContent()));
+ assertEquals(500, post.getStatusCode());
+ }
+
+ public void testHttpSoap12FaultOnEnvelope() throws Exception {
+ initSoapEndpoints(true);
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep2/");
+ post.setRequestEntity(new StringRequestEntity("<hello>world</hello>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ Element elem = transformer.toDOMElement(new StringSource(res));
+ assertEquals(Soap12.getInstance().getEnvelope(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap12.getInstance().getBody(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap12.getInstance().getFault(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(SoapConstants.SOAP_12_FAULTCODE, DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(SoapConstants.SOAP_12_FAULTVALUE, DomUtil.getQName(elem));
+ assertEquals(SoapConstants.SOAP_12_CODE_SENDER, DomUtil.createQName(elem, elem.getTextContent()));
+ elem = DomUtil.getNextSiblingElement(elem);
+ assertEquals(SoapConstants.SOAP_12_FAULTSUBCODE, DomUtil.getQName(elem));
+ assertEquals(SoapConstants.SOAP_12_CODE_VERSIONMISMATCH, DomUtil.createQName(elem, elem.getTextContent()));
+ assertEquals(500, post.getStatusCode());
+ }
+
+ public void testHttpSoap11UnkownOp() throws Exception {
+ initSoapEndpoints(true);
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep1/");
+ post.setRequestEntity(new StringRequestEntity("<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><hello>world</hello></s:Body></s:Envelope>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ Element elem = transformer.toDOMElement(new StringSource(res));
+ assertEquals(Soap11.getInstance().getEnvelope(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap11.getInstance().getBody(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap11.getInstance().getFault(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(SoapConstants.SOAP_11_FAULTCODE, DomUtil.getQName(elem));
+ assertEquals(SoapConstants.SOAP_11_CODE_CLIENT, DomUtil.createQName(elem, elem.getTextContent()));
+ assertEquals(500, post.getStatusCode());
+ }
+
+ /*
+ public void testHttpSoapAttachments() throws Exception {
+ initSoapEndpoints(true);
+
+ HttpComponent http = new HttpComponent();
+ HttpEndpoint ep0 = new HttpEndpoint();
+ ep0.setService(new QName("urn:test", "s0"));
+ ep0.setEndpoint("ep0");
+ ep0.setLocationURI("http://localhost:8192/ep1/");
+ ep0.setRoleAsString("provider");
+ ep0.setSoapVersion("1.1");
+ ep0.setSoap(true);
+ http.setEndpoints(new HttpEndpoint[] { ep0 });
+ container.activateComponent(http, "http2");
+
+ MockServiceComponent echo = new MockServiceComponent();
+ echo.setService(new QName("urn:test", "echo"));
+ echo.setEndpoint("endpoint");
+ echo.setResponseXml("<jbi:message xmlns:jbi='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'><jbi:part><HelloResponse xmlns='uri:HelloWorld' /></jbi:part></jbi:message>");
+ container.activateComponent(echo, "echo");
+
+ DefaultServiceMixClient client = new DefaultServiceMixClient(container);
+ Destination d = client.createDestination("service:urn:test:s0");
+ InOut me = d.createInOutExchange();
+ me.getInMessage().setContent(new StringSource("<HelloRequest xmlns='uri:HelloWorld'/>"));
+ Map<QName, DocumentFragment> headers = new HashMap<QName, DocumentFragment>();
+ Document doc = DOMUtil.newDocument();
+ DocumentFragment fragment = doc.createDocumentFragment();
+ DomUtil.createElement(fragment, new QName("uri:HelloWorld", "HelloHeader"));
+ headers.put(new QName("uri:HelloWorld", "HelloHeader"), fragment);
+ me.getInMessage().setProperty(org.apache.servicemix.JbiConstants.SOAP_HEADERS, headers);
+ File f = new File(getClass().getResource("servicemix.jpg").getFile());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ FileUtil.copyInputStream(new FileInputStream(f), baos);
+ DataSource ds = new ByteArrayDataSource(baos.toByteArray(), "image/jpeg");
+ DataHandler dh = new DataHandler(ds);
+ me.getInMessage().addAttachment("image", dh);
+ client.sendSync(me);
+ assertEquals(ExchangeStatus.ACTIVE, me.getStatus());
+ assertNull(me.getFault());
+ assertEquals(1, me.getOutMessage().getAttachmentNames().size());
+ client.done(me);
+ }
+ */
+
+ public void testHttpSoap11() throws Exception {
+ initSoapEndpoints(true);
+
+ MockServiceComponent echo = new MockServiceComponent();
+ echo.setService(new QName("urn:test", "echo"));
+ echo.setEndpoint("endpoint");
+ echo.setResponseXml("<jbi:message xmlns:jbi='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'><jbi:part><HelloResponse xmlns='uri:HelloWorld' /></jbi:part></jbi:message>");
+ container.activateComponent(echo, "echo");
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep1/");
+ post.setRequestEntity(new StringRequestEntity("<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Header><HelloHeader xmlns='uri:HelloWorld'/></s:Header><s:Body><HelloRequest xmlns='uri:HelloWorld'>world</HelloRequest></s:Body></s:Envelope>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ Element elem = transformer.toDOMElement(new StringSource(res));
+ assertEquals(Soap11.getInstance().getEnvelope(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap11.getInstance().getBody(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(new QName("uri:HelloWorld", "HelloResponse"), DomUtil.getQName(elem));
+ assertEquals(200, post.getStatusCode());
+ }
+
+ public void testHttpSoap12() throws Exception {
+ initSoapEndpoints(true);
+
+ TransformComponentSupport mock = new TransformComponentSupport() {
+ protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException {
+ Element elem;
+ try {
+ elem = transformer.toDOMElement(in.getContent());
+ System.err.println(transformer.toString(elem));
+ } catch (Exception e) {
+ throw new MessagingException(e);
+ }
+ assertEquals(JbiConstants.WSDL11_WRAPPER_MESSAGE, DomUtil.getQName(elem));
+ out.setContent(new StringSource("<jbi:message xmlns:jbi='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'><jbi:part><HelloResponse xmlns='uri:HelloWorld'>world</HelloResponse></jbi:part></jbi:message> "));
+ return true;
+ }
+ };
+ mock.setService(new QName("urn:test", "echo"));
+ mock.setEndpoint("endpoint");
+ container.activateComponent(mock, "mock");
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep2/");
+ post.setRequestEntity(new StringRequestEntity("<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'><s:Header><HelloHeader xmlns='uri:HelloWorld'/></s:Header><s:Body><HelloRequest xmlns='uri:HelloWorld'>world</HelloRequest></s:Body></s:Envelope>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ Element elem = transformer.toDOMElement(new StringSource(res));
+ assertEquals(Soap12.getInstance().getEnvelope(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap12.getInstance().getBody(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(new QName("uri:HelloWorld", "HelloResponse"), DomUtil.getQName(elem));
+ assertEquals(200, post.getStatusCode());
+ }
+
+ public void testHttpSoap12WithoutJbiWrapper() throws Exception {
+ initSoapEndpoints(false);
+
+ TransformComponentSupport mock = new TransformComponentSupport() {
+ protected boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException {
+ Element elem;
+ try {
+ elem = transformer.toDOMElement(in.getContent());
+ System.err.println(transformer.toString(elem));
+ } catch (Exception e) {
+ throw new MessagingException(e);
+ }
+ assertEquals(new QName("uri:HelloWorld", "HelloRequest"), DomUtil.getQName(elem));
+ out.setContent(new StringSource("<HelloResponse xmlns='uri:HelloWorld'>world</HelloResponse>"));
+ return true;
+ }
+ };
+ mock.setCopyProperties(false);
+ mock.setService(new QName("urn:test", "echo"));
+ mock.setEndpoint("endpoint");
+ container.activateComponent(mock, "mock");
+
+ PostMethod post = new PostMethod("http://localhost:8192/ep2/");
+ post.setRequestEntity(new StringRequestEntity("<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'><s:Header><HelloHeader xmlns='uri:HelloWorld'/></s:Header><s:Body><HelloRequest xmlns='uri:HelloWorld'>world</HelloRequest></s:Body></s:Envelope>"));
+ new HttpClient().executeMethod(post);
+ String res = post.getResponseBodyAsString();
+ System.err.println(res);
+ Element elem = transformer.toDOMElement(new StringSource(res));
+ assertEquals(Soap12.getInstance().getEnvelope(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(Soap12.getInstance().getBody(), DomUtil.getQName(elem));
+ elem = DomUtil.getFirstChildElement(elem);
+ assertEquals(new QName("uri:HelloWorld", "HelloResponse"), DomUtil.getQName(elem));
+ assertEquals(200, post.getStatusCode());
+ }
+
+}
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/ConsumerEndpointTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java?view=diff&rev=516106&r1=516105&r2=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/java/org/apache/servicemix/http/endpoints/SerializedMarshalerTest.java Thu Mar 8 09:22:25 2007
@@ -1,3 +1,19 @@
+/*
+ * 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.http.endpoints;
import javax.jbi.component.ComponentContext;
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl?view=auto&rev=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl Thu Mar 8 09:22:25 2007
@@ -0,0 +1,125 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+<definitions name="Hello"
+ targetNamespace="uri:HelloWorld"
+ xmlns:tns="uri:HelloWorld"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="uri:HelloWorld"
+ xmlns="http://www.w3.org/2000/10/XMLSchema">
+ <element name="HelloRequest">
+ <complexType>
+ <all>
+ <element name="text" type="string"/>
+ </all>
+ </complexType>
+ </element>
+ <element name="HelloResponse">
+ <complexType>
+ <all>
+ <element name="text" type="string"/>
+ </all>
+ </complexType>
+ </element>
+ <element name="HelloHeader">
+ <complexType>
+ <all>
+ <element name="id" type="string"/>
+ </all>
+ </complexType>
+ </element>
+ <element name="HelloFault">
+ <complexType>
+ <all>
+ <element name="id" type="string"/>
+ </all>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="HelloRequest">
+ <part name="body" element="tns:HelloRequest"/>
+ <part name="header1" element="tns:HelloHeader"/>
+ </message>
+
+ <message name="HelloResponse">
+ <part name="body" element="tns:HelloResponse"/>
+ </message>
+
+ <message name="HelloFault">
+ <part name="body" element="tns:HelloFault"/>
+ </message>
+
+ <portType name="HelloPortType">
+ <operation name="Hello">
+ <input message="tns:HelloRequest"/>
+ <output message="tns:HelloResponse"/>
+ <fault name="fault" message="tns:HelloFault" />
+ </operation>
+ </portType>
+
+ <binding name="HelloSoap11Binding" type="tns:HelloPortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="Hello">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" parts="body"/>
+ <soap:header use="literal" message="tns:HelloRequest" part="header1"/>
+ </input>
+ <output>
+ <soap:body use="literal" parts="body"/>
+ </output>
+ <fault name="fault">
+ <soap:fault name="fault" use="literal" />
+ </fault>
+ </operation>
+ </binding>
+
+ <binding name="HelloSoap12Binding" type="tns:HelloPortType">
+ <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="Hello">
+ <soap12:operation soapAction=""/>
+ <input>
+ <soap12:body use="literal" parts="body"/>
+ <soap12:header use="literal" message="tns:HelloRequest" part="header1"/>
+ </input>
+ <output>
+ <soap12:body use="literal" parts="body"/>
+ </output>
+ <fault name="fault">
+ <soap12:fault name="fault" use="literal" />
+ </fault>
+ </operation>
+ </binding>
+
+ <service name="HelloService">
+ <port name="HelloPortSoap11" binding="tns:HelloSoap11Binding">
+ <soap:address location="http://localhost:8080/hello"/>
+ </port>
+ <port name="HelloPortSoap12" binding="tns:HelloSoap12Binding">
+ <soap12:address location="http://localhost:8080/hello"/>
+ </port>
+ </service>
+
+</definitions>
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-DOC.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl?view=auto&rev=516106
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl Thu Mar 8 09:22:25 2007
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+<definitions name="Hello"
+ targetNamespace="uri:HelloWorld"
+ xmlns:tns="uri:HelloWorld"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="uri:HelloWorld"
+ xmlns="http://www.w3.org/2000/10/XMLSchema">
+ <element name="HelloHeader1">
+ <complexType>
+ <all>
+ <element name="id1" type="string"/>
+ </all>
+ </complexType>
+ </element>
+ <element name="HelloHeader2">
+ <complexType>
+ <all>
+ <element name="id2" type="string"/>
+ </all>
+ </complexType>
+ </element>
+ </schema>
+ </types>
+
+ <message name="HelloRequest">
+ <part name="header1" element="tns:HelloHeader1"/>
+ <part name="header2" element="tns:HelloHeader2"/>
+ <part name="param1" type="xsd:string"/>
+ <part name="param2" type="xsd:int"/>
+ </message>
+
+ <message name="HelloResponse">
+ <part name="text" type="xsd:string"/>
+ </message>
+
+ <portType name="HelloPortType">
+ <operation name="Hello">
+ <input message="tns:HelloRequest"/>
+ <output message="tns:HelloResponse"/>
+ </operation>
+ </portType>
+
+ <binding name="HelloSoapBinding" type="tns:HelloPortType">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="Hello">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal" parts="param1 param2" namespace="uri:HelloWorld"/>
+ <soap:header use="literal" message="tns:HelloRequest" part="header1"/>
+ <soap:header use="literal" message="tns:HelloRequest" part="header2"/>
+ </input>
+ <output>
+ <soap:body use="literal" parts="text" namespace="uri:HelloWorld"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="HelloService">
+ <port name="HelloPort" binding="tns:HelloSoapBinding">
+ <soap:address location="http://localhost:8080/hello"/>
+ </port>
+ </service>
+
+</definitions>
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/test/resources/org/apache/servicemix/http/HelloWorld-RPC.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml