Author: veithen Date: Sat Oct 10 22:17:03 2015 New Revision: 1707922 URL: http://svn.apache.org/viewvc?rev=1707922&view=rev Log: Some experimental code that implements a Spring Integration outbound gateway based on Axiom.
Added: webservices/axiom/experimental/axiom-spring-integration/ (with props) webservices/axiom/experimental/axiom-spring-integration/pom.xml (with props) webservices/axiom/experimental/axiom-spring-integration/src/ webservices/axiom/experimental/axiom-spring-integration/src/main/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/MarshallerOMDataSource.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/WebServiceOutboundGateway.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/NamespaceHandler.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/WebServiceOutboundGatewayParser.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/main/resources/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.handlers webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.schemas webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/integration/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/integration/config/ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/integration/config/schema.xsd webservices/axiom/experimental/axiom-spring-integration/src/test/ webservices/axiom/experimental/axiom-spring-integration/src/test/java/ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileService.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileServiceImpl.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileRequest.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileResponse.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/WebServiceOutboundGatewayTest.java (with props) webservices/axiom/experimental/axiom-spring-integration/src/test/resources/ webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/ webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/ webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/ webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/ webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/integration/ webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/integration/mtom-client-context.xml (with props) Propchange: webservices/axiom/experimental/axiom-spring-integration/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Oct 10 22:17:03 2015 @@ -0,0 +1,4 @@ +.classpath +.project +.settings +target Added: webservices/axiom/experimental/axiom-spring-integration/pom.xml URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/pom.xml?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/pom.xml (added) +++ webservices/axiom/experimental/axiom-spring-integration/pom.xml Sat Oct 10 22:17:03 2015 @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.ws.commons.axiom</groupId> + <artifactId>experimental</artifactId> + <version>1.2.16-SNAPSHOT</version> + </parent> + + <artifactId>axiom-spring-integration</artifactId> + + <dependencies> + <dependency> + <groupId>org.springframework.integration</groupId> + <artifactId>spring-integration-core</artifactId> + <version>4.2.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-oxm</artifactId> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>axiom-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>axiom-impl</artifactId> + <version>${project.version}</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>com.google.truth</groupId> + <artifactId>truth</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>testutils</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxws</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http-jetty</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-maven-plugin</artifactId> + <configuration> + <signature> + <groupId>org.codehaus.mojo.signature</groupId> + <artifactId>java17</artifactId> + <version>1.0</version> + </signature> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: webservices/axiom/experimental/axiom-spring-integration/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/MarshallerOMDataSource.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/MarshallerOMDataSource.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/MarshallerOMDataSource.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/MarshallerOMDataSource.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,68 @@ +/* + * 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.axiom.spring.integration; + +import java.io.IOException; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.stax.StAXResult; + +import org.apache.axiom.om.ds.AbstractPushOMDataSource; +import org.apache.axiom.util.stax.wrapper.XMLStreamWriterWrapper; +import org.springframework.oxm.Marshaller; + +final class MarshallerOMDataSource extends AbstractPushOMDataSource { + private final Marshaller marshaller; + private final Object payload; + + MarshallerOMDataSource(Marshaller marshaller, Object payload) { + this.marshaller = marshaller; + this.payload = payload; + } + + public boolean isDestructiveWrite() { + return false; + } + + public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException { + try { + // TODO: MIME support here + marshaller.marshal(payload, new StAXResult(new XMLStreamWriterWrapper(xmlWriter) { + @Override + public void writeStartDocument() { + } + + @Override + public void writeStartDocument(String encoding, String version) { + } + + @Override + public void writeStartDocument(String version) { + } + + @Override + public void writeEndDocument() { + } + })); + } catch (IOException ex) { + throw new XMLStreamException(ex); + } + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/MarshallerOMDataSource.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/WebServiceOutboundGateway.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/WebServiceOutboundGateway.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/WebServiceOutboundGateway.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/WebServiceOutboundGateway.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,97 @@ +/* + * 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.axiom.spring.integration; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.ParseException; + +import javax.xml.stream.XMLStreamException; +import javax.xml.transform.stax.StAXSource; + +import org.apache.axiom.attachments.Attachments; +import org.apache.axiom.mime.ContentType; +import org.apache.axiom.mime.MediaType; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMMetaFactory; +import org.apache.axiom.om.OMOutputFormat; +import org.apache.axiom.om.OMXMLBuilderFactory; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axiom.soap.SOAPMessage; +import org.apache.axiom.soap.SOAPModelBuilder; +import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; +import org.springframework.messaging.Message; +import org.springframework.messaging.MessageDeliveryException; +import org.springframework.oxm.Marshaller; +import org.springframework.oxm.Unmarshaller; + +public final class WebServiceOutboundGateway extends AbstractReplyProducingMessageHandler { + private final OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(); + private boolean useSOAP12; // TODO: find better convention + private final URL url; + private final Marshaller marshaller; + private final Unmarshaller unmarshaller; + private SOAPFactory soapFactory; + + public WebServiceOutboundGateway(URL url, Marshaller marshaller, Unmarshaller unmarshaller) { + this.url = url; + this.marshaller = marshaller; + this.unmarshaller = unmarshaller; + } + public void setUseSOAP12(boolean useSOAP12) { + this.useSOAP12 = useSOAP12; + } + + @Override + protected void doInit() { + soapFactory = useSOAP12 ? metaFactory.getSOAP12Factory() : metaFactory.getSOAP11Factory(); + } + + @Override + protected Object handleRequestMessage(Message<?> requestMessage) { + SOAPMessage soapMessage = soapFactory.createDefaultSOAPMessage(); + soapMessage.getSOAPEnvelope().getBody().addChild(soapFactory.createOMElement( + new MarshallerOMDataSource(marshaller, requestMessage.getPayload()))); + OMOutputFormat format = new OMOutputFormat(); + format.setSOAP11(!useSOAP12); + try { + HttpURLConnection connection = (HttpURLConnection)url.openConnection(); + connection.setDoOutput(true); + connection.setChunkedStreamingMode(0); + connection.setRequestProperty("Content-Type", format.getContentType()); + OutputStream out = connection.getOutputStream(); + // TODO: SOAP action + // TODO: disable XML declaration + soapMessage.serializeAndConsume(out, format); + out.close(); + ContentType contentType = new ContentType(connection.getContentType()); + if (contentType.getMediaType().equals(MediaType.MULTIPART_RELATED)) { + SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder( + new Attachments(connection.getInputStream(), contentType.toString())); + return unmarshaller.unmarshal(new StAXSource(builder.getSOAPEnvelope().getBody().getFirstElement().getXMLStreamReader(false))); + } + } catch (IOException | XMLStreamException | ParseException ex) { + throw new MessageDeliveryException(requestMessage, ex); + } + // TODO + return null; + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/WebServiceOutboundGateway.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/NamespaceHandler.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/NamespaceHandler.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/NamespaceHandler.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/NamespaceHandler.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,28 @@ +/* + * 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.axiom.spring.integration.config; + +import org.springframework.beans.factory.xml.NamespaceHandlerSupport; + +public class NamespaceHandler extends NamespaceHandlerSupport { + @Override + public void init() { + registerBeanDefinitionParser("ws-outbound-gateway", new WebServiceOutboundGatewayParser()); + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/NamespaceHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/WebServiceOutboundGatewayParser.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/WebServiceOutboundGatewayParser.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/WebServiceOutboundGatewayParser.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/WebServiceOutboundGatewayParser.java Sat Oct 10 22:17:03 2015 @@ -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.axiom.spring.integration.config; + +import org.apache.axiom.spring.integration.WebServiceOutboundGateway; +import org.springframework.beans.factory.support.BeanDefinitionBuilder; +import org.springframework.beans.factory.xml.ParserContext; +import org.springframework.integration.config.xml.AbstractOutboundGatewayParser; +import org.w3c.dom.Element; + +public final class WebServiceOutboundGatewayParser extends AbstractOutboundGatewayParser { + @Override + protected String getGatewayClassName(Element element) { + return WebServiceOutboundGateway.class.getName(); + } + + @Override + protected void postProcessGateway(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) { + builder.addConstructorArgReference(element.getAttribute("marshaller")); + builder.addConstructorArgReference(element.getAttribute("unmarshaller")); + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/main/java/org/apache/axiom/spring/integration/config/WebServiceOutboundGatewayParser.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.handlers URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.handlers?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.handlers (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.handlers Sat Oct 10 22:17:03 2015 @@ -0,0 +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. +# +http\://ws.apache.org/axiom/spring-integration=org.apache.axiom.spring.integration.config.NamespaceHandler Added: webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.schemas URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.schemas?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.schemas (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/META-INF/spring.schemas Sat Oct 10 22:17:03 2015 @@ -0,0 +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. +# +http\://ws.apache.org/axiom/schema/spring-integration.xsd=org/apache/axiom/spring/integration/config/schema.xsd Added: webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/integration/config/schema.xsd URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/integration/config/schema.xsd?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/integration/config/schema.xsd (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/main/resources/org/apache/axiom/spring/integration/config/schema.xsd Sat Oct 10 22:17:03 2015 @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tool="http://www.springframework.org/schema/tool" + xmlns="http://ws.apache.org/axiom/spring-integration" + targetNamespace="http://ws.apache.org/axiom/spring-integration" + elementFormDefault="qualified"> + <xsd:element name="ws-outbound-gateway"> + <xsd:complexType> + <xsd:attribute name="request-channel" type="xsd:string"> + <xsd:annotation> + <xsd:documentation>The channel where Messages should be sent to invoke the Web Service.</xsd:documentation> + <xsd:appinfo> + <tool:annotation kind="ref"> + <tool:expected-type type="org.springframework.messaging.MessageChannel"/> + </tool:annotation> + </xsd:appinfo> + </xsd:annotation> + </xsd:attribute> + <xsd:attribute name="url" type="xsd:string" use="required"> + <xsd:annotation> + <xsd:documentation>The Destination URL for this Web Service Gateway.</xsd:documentation> + </xsd:annotation> + </xsd:attribute> + <xsd:attribute name="marshaller" type="xsd:string" use="required"> + <xsd:annotation> + <xsd:documentation>Reference to a Spring OXM Mashaller.</xsd:documentation> + <xsd:appinfo> + <tool:annotation kind="ref"> + <tool:expected-type type="org.springframework.oxm.Marshaller"/> + </tool:annotation> + </xsd:appinfo> + </xsd:annotation> + </xsd:attribute> + <xsd:attribute name="unmarshaller" type="xsd:string" use="required"> + <xsd:annotation> + <xsd:documentation>Reference to a Spring OXM Unmarshaller.</xsd:documentation> + <xsd:appinfo> + <tool:annotation kind="ref"> + <tool:expected-type type="org.springframework.oxm.Unmarshaller"/> + </tool:annotation> + </xsd:appinfo> + </xsd:annotation> + </xsd:attribute> + </xsd:complexType> + </xsd:element> +</xsd:schema> Added: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileService.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileService.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileService.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileService.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,23 @@ +/* + * 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.axiom.spring.integration; + +public interface FileService { + GetFileResponse getFile(GetFileRequest request); +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileService.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileServiceImpl.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileServiceImpl.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileServiceImpl.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileServiceImpl.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,42 @@ +/* + * 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.axiom.spring.integration; + +import javax.activation.DataHandler; +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.xml.ws.RequestWrapper; +import javax.xml.ws.ResponseWrapper; +import javax.xml.ws.soap.MTOM; + +import org.apache.axiom.testutils.activation.RandomDataSource; + +@WebService(targetNamespace="urn:test") +@MTOM +public class FileServiceImpl { + @WebMethod + @RequestWrapper(className="org.apache.axiom.spring.integration.GetFileRequest", localName="getFileRequest") + @ResponseWrapper(className="org.apache.axiom.spring.integration.GetFileResponse", localName="getFileResponse") + @WebResult(name="content") + public DataHandler getFile(@WebParam(name="seed") long seed, @WebParam(name="length") long length) { + return new DataHandler(new RandomDataSource(seed, length)); + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/FileServiceImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileRequest.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileRequest.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileRequest.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileRequest.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,48 @@ +/* + * 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.axiom.spring.integration; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlRootElement(namespace="urn:test") +@XmlType(propOrder={"seed", "length"}) +public class GetFileRequest { + private long seed; + private long length; + + @XmlElement + public long getSeed() { + return seed; + } + + public void setSeed(long seed) { + this.seed = seed; + } + + @XmlElement + public long getLength() { + return length; + } + + public void setLength(long length) { + this.length = length; + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileRequest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileResponse.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileResponse.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileResponse.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileResponse.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,37 @@ +/* + * 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.axiom.spring.integration; + +import javax.activation.DataHandler; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(namespace="urn:test") +public class GetFileResponse { + private DataHandler content; + + @XmlElement + public DataHandler getContent() { + return content; + } + + public void setContent(DataHandler content) { + this.content = content; + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/GetFileResponse.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/WebServiceOutboundGatewayTest.java URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/WebServiceOutboundGatewayTest.java?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/WebServiceOutboundGatewayTest.java (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/WebServiceOutboundGatewayTest.java Sat Oct 10 22:17:03 2015 @@ -0,0 +1,62 @@ +/* + * 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.axiom.spring.integration; + +import javax.xml.ws.Endpoint; + +import org.apache.axiom.testutils.PortAllocator; +import org.apache.axiom.testutils.activation.RandomDataSource; +import org.apache.axiom.testutils.io.IOTestUtils; +import org.junit.Test; +import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.context.support.GenericXmlApplicationContext; +import org.springframework.core.env.StandardEnvironment; +import org.springframework.core.io.ClassPathResource; +import org.springframework.mock.env.MockPropertySource; + +public class WebServiceOutboundGatewayTest { + @Test + public void test() throws Exception { + int port = PortAllocator.allocatePort(); + Endpoint endpoint = Endpoint.publish("http://localhost:" + port + "/mtom", new FileServiceImpl()); + try { + GenericXmlApplicationContext context = new GenericXmlApplicationContext(); + MockPropertySource propertySource = new MockPropertySource("client-properties"); + propertySource.setProperty("port", port); + context.getEnvironment().getPropertySources().replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, propertySource); + XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); + reader.loadBeanDefinitions(new ClassPathResource("mtom-client-context.xml", WebServiceOutboundGatewayTest.class)); + context.refresh(); + try { + FileService fileService = context.getBean(FileService.class); + GetFileRequest request = new GetFileRequest(); + request.setSeed(12345678); + request.setLength(4096); + GetFileResponse response = fileService.getFile(request); + IOTestUtils.compareStreams( + response.getContent().getInputStream(), + new RandomDataSource(request.getSeed(), request.getLength()).getInputStream()); + } finally { + context.close(); + } + } finally { + endpoint.stop(); + } + } +} Propchange: webservices/axiom/experimental/axiom-spring-integration/src/test/java/org/apache/axiom/spring/integration/WebServiceOutboundGatewayTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/integration/mtom-client-context.xml URL: http://svn.apache.org/viewvc/webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/integration/mtom-client-context.xml?rev=1707922&view=auto ============================================================================== --- webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/integration/mtom-client-context.xml (added) +++ webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/integration/mtom-client-context.xml Sat Oct 10 22:17:03 2015 @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- + ~ 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. + --> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:oxm="http://www.springframework.org/schema/oxm" + xmlns:int="http://www.springframework.org/schema/integration" + xmlns:axiom="http://ws.apache.org/axiom/spring-integration" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd + http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-4.2.xsd + http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-4.2.xsd + http://ws.apache.org/axiom/spring-integration http://ws.apache.org/axiom/schema/spring-integration.xsd"> + <int:channel id="request"/> + <int:gateway id="fileService" service-interface="org.apache.axiom.spring.integration.FileService" default-request-channel="request"/> + <oxm:jaxb2-marshaller id="marshaller"> + <oxm:class-to-be-bound name="org.apache.axiom.spring.integration.GetFileRequest"/> + <oxm:class-to-be-bound name="org.apache.axiom.spring.integration.GetFileResponse"/> + </oxm:jaxb2-marshaller> + <axiom:ws-outbound-gateway request-channel="request" url="http://localhost:${port}/mtom" + marshaller="marshaller" unmarshaller="marshaller"/> +</beans> Propchange: webservices/axiom/experimental/axiom-spring-integration/src/test/resources/org/apache/axiom/spring/integration/mtom-client-context.xml ------------------------------------------------------------------------------ svn:eol-style = native