Upgrade to Jakarta EE 9.

Resolves #1213.
This commit is contained in:
Greg L. Turnquist
2021-11-01 10:30:28 -05:00
parent f61913c2ed
commit 84a1b79436
251 changed files with 2550 additions and 12143 deletions

76
Jenkinsfile vendored
View File

@@ -11,7 +11,7 @@ pipeline {
}
stages {
stage('Publish OpenJDK 8 + jq docker image') {
stage('Publish OpenJDK 17 + jq docker image') {
when {
changeset "ci/Dockerfile"
}
@@ -19,7 +19,7 @@ pipeline {
steps {
script {
def image = docker.build("springci/spring-ws-openjdk8-with-jq", "ci/")
def image = docker.build("springci/spring-ws-openjdk17-with-jq", "ci/")
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
image.push()
}
@@ -27,10 +27,10 @@ pipeline {
}
}
stage("Test: baseline (jdk8)") {
stage("Test: baseline (jdk17)") {
agent {
docker {
image 'adoptopenjdk/openjdk8:latest'
image 'openjdk:17-bullseye'
args '-v $HOME/.m2:/root/.m2'
}
}
@@ -44,10 +44,10 @@ pipeline {
stage("Test other configurations") {
parallel {
stage("Test: spring-buildsnapshot (jdk8)") {
stage("Test: spring-buildsnapshot (jdk17)") {
agent {
docker {
image 'adoptopenjdk/openjdk8:latest'
image 'openjdk:17-bullseye'
args '-v $HOME/.m2:/root/.m2'
}
}
@@ -58,69 +58,13 @@ pipeline {
sh "PROFILE=spring-buildsnapshot,convergence ci/test.sh"
}
}
stage("Test: baseline (jdk11)") {
agent {
docker {
image 'adoptopenjdk/openjdk11:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
sh "PROFILE=distribute,java11,convergence ci/test.sh"
}
}
stage("Test: spring-buildsnapshot (jdk11)") {
agent {
docker {
image 'adoptopenjdk/openjdk11:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
sh "PROFILE=spring-buildsnapshot,java11,convergence ci/test.sh"
}
}
stage("Test: baseline (jdk16)") {
agent {
docker {
image 'adoptopenjdk/openjdk16:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
sh "PROFILE=distribute,java11,convergence ci/test.sh"
}
}
stage("Test: spring-buildsnapshot (jdk16)") {
agent {
docker {
image 'adoptopenjdk/openjdk16:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
}
steps {
sh "PROFILE=spring-buildsnapshot,java11,convergence ci/test.sh"
}
}
}
}
stage('Deploy') {
agent {
docker {
image 'springci/spring-ws-openjdk8-with-jq:latest'
image 'springci/spring-ws-openjdk17-with-jq:latest'
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
}
}
@@ -167,13 +111,13 @@ pipeline {
stage('Release documentation') {
when {
anyOf {
branch 'main'
branch 'release'
branch '4.0.x'
branch 'release-4.0.x'
}
}
agent {
docker {
image 'adoptopenjdk/openjdk8:latest'
image 'openjdk:17-bullseye'
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
}
}

View File

@@ -38,9 +38,9 @@ You can also import the project into your IDE.
2. With the release tagged, push the tagged version to the release branch.
+
----
% git checkout -b release
% git checkout -b release-4.0.x
% git reset --hard <tag>
% git push -f origin release
% git push -f origin release-4.0.x
----
NOTE: You can chain the previous set of commands together using `&&`.

View File

@@ -1,4 +1,4 @@
FROM adoptopenjdk/openjdk8:latest
FROM openjdk:17-bullseye
RUN apt-get update && apt-get install -y jq gpg

1653
pom.xml

File diff suppressed because it is too large Load Diff

View File

@@ -2,232 +2,254 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<parent>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>spring-ws-core</artifactId>
<packaging>jar</packaging>
<artifactId>spring-ws-core</artifactId>
<packaging>jar</packaging>
<description>Spring WS Core</description>
<description>Spring WS Core</description>
<dependencies>
<dependencies>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
<scope>test</scope>
</dependency>
<!--// XML-->
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>${jdom2.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>${dom4j.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>${xom.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
<version>${xml-schema-core.version}</version>
<optional>true</optional>
</dependency>
<!--// XML-->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jakarta-xml-bind.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jakarta-xml-bind.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>${jdom2.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>${dom4j.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>${xom.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
<version>${xml-schema-core.version}</version>
<optional>true</optional>
</dependency>
<!--// SOAP-->
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>${axiom.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-impl</artifactId>
<version>${axiom.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>wstx-asl</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--// WSDL-->
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>${wsdl4j.version}</version>
<optional>true</optional>
</dependency>
<!--// WSDL-->
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>${wsdl4j.version}</version>
<optional>true</optional>
</dependency>
<!--// Transport-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>${commons-httpclient.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--// Transport-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax-servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>${commons-httpclient.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--// Mail-->
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
<version>${jakarta-mail.version}</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>${jakarta-mail.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<profiles>
<profile>
<id>docs</id>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>2.14.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
<scope>test</scope>
</dependency>
</profile>
</profiles>
</dependencies>
</project>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -59,7 +59,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
private static final boolean dom4jPresent = ClassUtils.isPresent("org.dom4j.Element",
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
private static final boolean jaxb2Present = ClassUtils.isPresent("javax.xml.bind.Binder",
private static final boolean jaxb2Present = ClassUtils.isPresent("jakarta.xml.bind.Binder",
AnnotationDrivenBeanDefinitionParser.class.getClassLoader());
private static final boolean jdomPresent = ClassUtils.isPresent("org.jdom2.Element",

View File

@@ -16,15 +16,15 @@
package org.springframework.ws.mime;
import jakarta.activation.DataHandler;
import jakarta.activation.DataSource;
import jakarta.activation.FileDataSource;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import org.springframework.core.io.InputStreamSource;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
@@ -81,7 +81,7 @@ public abstract class AbstractMimeMessage implements MimeMessage {
@Override
public OutputStream getOutputStream() {
throw new UnsupportedOperationException("Read-only javax.activation.DataSource");
throw new UnsupportedOperationException("Read-only jakarta.activation.DataSource");
}
@Override

View File

@@ -16,11 +16,11 @@
package org.springframework.ws.mime;
import jakarta.activation.DataHandler;
import java.io.IOException;
import java.io.InputStream;
import javax.activation.DataHandler;
/**
* Represents an attachment to a {@link org.springframework.ws.mime.MimeMessage}
*

View File

@@ -16,11 +16,11 @@
package org.springframework.ws.mime;
import jakarta.activation.DataHandler;
import java.io.File;
import java.util.Iterator;
import javax.activation.DataHandler;
import org.springframework.core.io.InputStreamSource;
import org.springframework.ws.WebServiceMessage;

View File

@@ -54,7 +54,7 @@ public class DefaultMethodEndpointAdapter extends AbstractMethodEndpointAdapter
private static final String DOM4J_CLASS_NAME = "org.dom4j.Element";
private static final String JAXB2_CLASS_NAME = "javax.xml.bind.Binder";
private static final String JAXB2_CLASS_NAME = "jakarta.xml.bind.Binder";
private static final String JDOM_CLASS_NAME = "org.jdom2.Element";

View File

@@ -16,6 +16,14 @@
package org.springframework.ws.server.endpoint.adapter.method.jaxb;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.JAXBIntrospector;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.UnmarshallerHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -25,13 +33,6 @@ import java.net.URL;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBIntrospector;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.UnmarshallerHandler;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
@@ -184,7 +185,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
/**
* Creates a new {@link Marshaller} to be used for marshalling objects to XML. Defaults to
* {@link javax.xml.bind.JAXBContext#createMarshaller()}, but can be overridden in subclasses for further
* {@link jakarta.xml.bind.JAXBContext#createMarshaller()}, but can be overridden in subclasses for further
* customization.
*
* @param jaxbContext the JAXB context to create a marshaller for
@@ -201,7 +202,7 @@ public abstract class AbstractJaxb2PayloadMethodProcessor extends AbstractPayloa
/**
* Creates a new {@link Unmarshaller} to be used for unmarshalling XML to objects. Defaults to
* {@link javax.xml.bind.JAXBContext#createUnmarshaller()}, but can be overridden in subclasses for further
* {@link jakarta.xml.bind.JAXBContext#createUnmarshaller()}, but can be overridden in subclasses for further
* customization.
*
* @param jaxbContext the JAXB context to create a unmarshaller for

View File

@@ -16,12 +16,12 @@
package org.springframework.ws.server.endpoint.adapter.method.jaxb;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import org.springframework.core.MethodParameter;
import org.springframework.ws.context.MessageContext;

View File

@@ -16,10 +16,10 @@
package org.springframework.ws.server.endpoint.adapter.method.jaxb;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import org.springframework.core.MethodParameter;
import org.springframework.ws.context.MessageContext;

View File

@@ -20,7 +20,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
import org.springframework.ws.transport.WebServiceConnection;
import org.springframework.ws.transport.context.TransportContext;
import org.springframework.ws.transport.context.TransportContextHolder;
@@ -38,22 +38,22 @@ import org.springframework.ws.transport.context.TransportContextHolder;
* <p>
* Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the {@code
* java.util.Properties} class, like as follows:
*
*
* <pre>
* http://example.com:8080/services/bookFlight=bookFlightEndpoint
* jms://exampleQueue=getFlightsEndpoint
* </pre>
*
*
* or, when the {@code usePath} property is enabled:
*
*
* <pre>
* /services/bookFlight=bookFlightEndpoint
* </pre>
*
*
* The syntax is [URI|PATH]=ENDPOINT_BEAN_NAME.
* <p>
* This endpoint mapping does not read from the request message, and therefore is more suitable for message factories
* which directly read from the transport request (such as the {@link AxiomSoapMessageFactory} with the {@code
* which directly read from the transport request (such as the {@link SaajSoapMessageFactory} with the {@code
* payloadCaching} disabled). However, this endpoint mapping obviously is transport specific.
*
* @author Arjen Poutsma

View File

@@ -16,12 +16,13 @@
package org.springframework.ws.server.endpoint.mapping.jaxb;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.JAXBIntrospector;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.lang.reflect.Method;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBIntrospector;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;
import org.springframework.core.MethodParameter;
@@ -35,7 +36,7 @@ import org.springframework.xml.transform.TransformerHelper;
* JAXB2 {@link XmlRootElement} annotation to map methods to request payload root elements.
* <p>
* Endpoints typically have the following form:
*
*
* <pre>
* &#64;Endpoint
* public class MyEndpoint{
@@ -44,9 +45,9 @@ import org.springframework.xml.transform.TransformerHelper;
* }
* }
* </pre>
*
*
* where MyRootElement is annotated with {@code @XmlRootElement}:
*
*
* <pre>
* &#64;XmlRootElement(name = "myRoot", namespace = "http://springframework.org/spring-ws")
* public class MyRootElement {

View File

@@ -1,87 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFactory;
import org.springframework.util.Assert;
import org.springframework.util.xml.StaxUtils;
import org.springframework.ws.soap.axiom.support.AxiomUtils;
/**
* Abstract base class for {@link Payload} implementations.
*
* @author Arjen Poutsma
* @since 2.0
*/
abstract class AbstractPayload extends Payload {
private final SOAPBody axiomBody;
private final SOAPFactory axiomFactory;
protected AbstractPayload(SOAPBody axiomBody, SOAPFactory axiomFactory) {
Assert.notNull(axiomBody, "'axiomBody' must not be null");
Assert.notNull(axiomFactory, "'axiomFactory' must not be null");
this.axiomBody = axiomBody;
this.axiomFactory = axiomFactory;
}
@Override
public final Source getSource() {
try {
OMElement payloadElement = getPayloadElement();
if (payloadElement != null) {
XMLStreamReader streamReader = getStreamReader(payloadElement);
return StaxUtils.createCustomStaxSource(streamReader);
} else {
return null;
}
} catch (OMException ex) {
throw new AxiomSoapBodyException(ex);
}
}
protected abstract XMLStreamReader getStreamReader(OMElement payloadElement);
@Override
public final Result getResult() {
AxiomUtils.removeContents(getAxiomBody());
return getResultInternal();
}
protected abstract Result getResultInternal();
public SOAPFactory getAxiomFactory() {
return axiomFactory;
}
protected SOAPBody getAxiomBody() {
return axiomBody;
}
protected OMElement getPayloadElement() throws OMException {
return getAxiomBody().getFirstElement();
}
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.io.IOException;
import java.io.InputStream;
import javax.activation.DataHandler;
import org.springframework.util.Assert;
import org.springframework.ws.mime.Attachment;
/**
* Axiom-specific implementation of {@link org.springframework.ws.mime.Attachment}
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomAttachment implements Attachment {
private final DataHandler dataHandler;
private final String contentId;
public AxiomAttachment(String contentId, DataHandler dataHandler) {
Assert.notNull(contentId, "contentId must not be null");
Assert.notNull(dataHandler, "dataHandler must not be null");
this.contentId = contentId;
this.dataHandler = dataHandler;
}
@Override
public String getContentId() {
return contentId;
}
@Override
public String getContentType() {
return dataHandler.getContentType();
}
@Override
public InputStream getInputStream() throws IOException {
return dataHandler.getInputStream();
}
@Override
public long getSize() {
// Axiom does not support getting the size of attachments.
return -1;
}
@Override
public DataHandler getDataHandler() {
return dataHandler;
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.mime.AttachmentException;
/** @author Arjen Poutsma */
@SuppressWarnings("serial")
public class AxiomAttachmentException extends AttachmentException {
public AxiomAttachmentException(String msg) {
super(msg);
}
public AxiomAttachmentException(String msg, Throwable ex) {
super(msg, ex);
}
public AxiomAttachmentException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,154 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.Locale;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultCode;
import org.apache.axiom.soap.SOAPFaultReason;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.axiom.support.AxiomUtils;
import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.Soap11Body}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoap11Body extends AxiomSoapBody implements Soap11Body {
private final boolean langAttributeOnSoap11FaultString;
AxiomSoap11Body(SOAPBody axiomBody, SOAPFactory axiomFactory, boolean payloadCaching,
boolean langAttributeOnSoap11FaultString) {
super(axiomBody, axiomFactory, payloadCaching);
this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
}
@Override
public Soap11Fault addMustUnderstandFault(String faultString, Locale locale) {
SOAPFault fault = addStandardFault(SOAP11Constants.FAULT_CODE_MUST_UNDERSTAND, faultString, locale);
return new AxiomSoap11Fault(fault, getAxiomFactory());
}
@Override
public Soap11Fault addClientOrSenderFault(String faultString, Locale locale) {
SOAPFault fault = addStandardFault(SOAP11Constants.FAULT_CODE_SENDER, faultString, locale);
return new AxiomSoap11Fault(fault, getAxiomFactory());
}
@Override
public Soap11Fault addServerOrReceiverFault(String faultString, Locale locale) {
SOAPFault fault = addStandardFault(SOAP11Constants.FAULT_CODE_RECEIVER, faultString, locale);
return new AxiomSoap11Fault(fault, getAxiomFactory());
}
@Override
public Soap11Fault addVersionMismatchFault(String faultString, Locale locale) {
SOAPFault fault = addStandardFault(SOAP11Constants.FAULT_CODE_VERSION_MISMATCH, faultString, locale);
return new AxiomSoap11Fault(fault, getAxiomFactory());
}
@Override
public Soap11Fault addFault(QName code, String faultString, Locale faultStringLocale) {
Assert.notNull(code, "No faultCode given");
Assert.hasLength(faultString, "faultString cannot be empty");
if (!StringUtils.hasLength(code.getNamespaceURI())) {
throw new IllegalArgumentException(
"A fault code with namespace and local part must be specific for a custom fault code");
}
if (!langAttributeOnSoap11FaultString) {
faultStringLocale = null;
}
try {
AxiomUtils.removeContents(getAxiomBody());
SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody());
SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault);
setValueText(code, fault, faultCode);
SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault);
if (faultStringLocale != null) {
addLangAttribute(faultStringLocale, faultReason);
}
faultReason.setText(faultString);
return new AxiomSoap11Fault(fault, getAxiomFactory());
} catch (SOAPProcessingException ex) {
throw new AxiomSoapFaultException(ex);
}
}
private void setValueText(QName code, SOAPFault fault, SOAPFaultCode faultCode) {
String prefix = code.getPrefix();
if (StringUtils.hasLength(code.getNamespaceURI()) && StringUtils.hasLength(prefix)) {
OMNamespace namespace = fault.findNamespaceURI(prefix);
if (namespace == null) {
fault.declareNamespace(code.getNamespaceURI(), prefix);
}
} else if (StringUtils.hasLength(code.getNamespaceURI())) {
OMNamespace namespace = fault.findNamespace(code.getNamespaceURI(), null);
if (namespace == null) {
namespace = fault.declareNamespace(code.getNamespaceURI(), "");
}
code = new QName(code.getNamespaceURI(), code.getLocalPart(), namespace.getPrefix());
}
faultCode.setText(code);
}
private SOAPFault addStandardFault(String localName, String faultString, Locale locale) {
Assert.notNull(faultString, "No faultString given");
try {
AxiomUtils.removeContents(getAxiomBody());
SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody());
SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault);
faultCode.setText(new QName(fault.getNamespace().getNamespaceURI(), localName, fault.getNamespace().getPrefix()));
SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault);
if (locale != null) {
addLangAttribute(locale, faultReason);
}
faultReason.setText(faultString);
return fault;
} catch (SOAPProcessingException ex) {
throw new AxiomSoapFaultException(ex);
}
}
private void addLangAttribute(Locale locale, SOAPFaultReason faultReason) {
OMNamespace xmlNamespace = getAxiomFactory().createOMNamespace("http://www.w3.org/XML/1998/namespace", "xml");
OMAttribute langAttribute = getAxiomFactory().createOMAttribute("lang", xmlNamespace,
AxiomUtils.toLanguage(locale));
faultReason.addAttribute(langAttribute);
}
@Override
public Soap11Fault getFault() {
SOAPFault axiomFault = getAxiomBody().getFault();
return axiomFault != null ? new AxiomSoap11Fault(axiomFault, getAxiomFactory()) : null;
}
}

View File

@@ -1,70 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.Locale;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.springframework.ws.soap.axiom.support.AxiomUtils;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.Soap11Fault}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoap11Fault extends AxiomSoapFault implements Soap11Fault {
AxiomSoap11Fault(SOAPFault axiomFault, SOAPFactory axiomFactory) {
super(axiomFault, axiomFactory);
}
@Override
public QName getFaultCode() {
return getAxiomFault().getCode().getTextAsQName();
}
@Override
public String getFaultStringOrReason() {
if (getAxiomFault().getReason() != null) {
return getAxiomFault().getReason().getText();
}
return null;
}
@Override
public Locale getFaultStringLocale() {
if (getAxiomFault().getReason() != null) {
OMAttribute langAttribute = getAxiomFault().getReason()
.getAttribute(new QName("http://www.w3.org/XML/1998/namespace", "lang"));
if (langAttribute != null) {
String xmlLangString = langAttribute.getAttributeValue();
if (xmlLangString != null) {
return AxiomUtils.toLocale(xmlLangString);
}
}
}
return null;
}
}

View File

@@ -1,62 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.axiom.soap.RolePlayer;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.springframework.util.ObjectUtils;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.soap11.Soap11Header;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.Soap11Header}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoap11Header extends AxiomSoapHeader implements Soap11Header {
AxiomSoap11Header(SOAPHeader axiomHeader, SOAPFactory axiomFactory) {
super(axiomHeader, axiomFactory);
}
@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineHeaderElementsToProcess(final String[] actors) {
RolePlayer rolePlayer = null;
if (!ObjectUtils.isEmpty(actors)) {
rolePlayer = new RolePlayer() {
public List<?> getRoles() {
return Arrays.asList(actors);
}
public boolean isUltimateDestination() {
return false;
}
};
}
Iterator<SOAPHeaderBlock> result = (Iterator<SOAPHeaderBlock>) getAxiomHeader().getHeadersToProcess(rolePlayer);
return new AxiomSoapHeaderElementIterator(result);
}
}

View File

@@ -1,110 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.Locale;
import javax.xml.namespace.QName;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultCode;
import org.apache.axiom.soap.SOAPFaultReason;
import org.apache.axiom.soap.SOAPFaultText;
import org.apache.axiom.soap.SOAPFaultValue;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.util.Assert;
import org.springframework.ws.soap.axiom.support.AxiomUtils;
import org.springframework.ws.soap.soap12.Soap12Body;
import org.springframework.ws.soap.soap12.Soap12Fault;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.Soap12Body}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoap12Body extends AxiomSoapBody implements Soap12Body {
AxiomSoap12Body(SOAPBody axiomBody, SOAPFactory axiomFactory, boolean payloadCaching) {
super(axiomBody, axiomFactory, payloadCaching);
}
@Override
public Soap12Fault addMustUnderstandFault(String reason, Locale locale) {
Assert.notNull(locale, "No locale given");
SOAPFault fault = addStandardFault(SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND, reason, locale);
return new AxiomSoap12Fault(fault, getAxiomFactory());
}
@Override
public Soap12Fault addClientOrSenderFault(String reason, Locale locale) {
Assert.notNull(locale, "No locale given");
SOAPFault fault = addStandardFault(SOAP12Constants.FAULT_CODE_SENDER, reason, locale);
return new AxiomSoap12Fault(fault, getAxiomFactory());
}
@Override
public Soap12Fault addServerOrReceiverFault(String reason, Locale locale) {
Assert.notNull(locale, "No locale given");
SOAPFault fault = addStandardFault(SOAP12Constants.FAULT_CODE_RECEIVER, reason, locale);
return new AxiomSoap12Fault(fault, getAxiomFactory());
}
@Override
public Soap12Fault addVersionMismatchFault(String reason, Locale locale) {
Assert.notNull(locale, "No locale given");
SOAPFault fault = addStandardFault(SOAP12Constants.FAULT_CODE_VERSION_MISMATCH, reason, locale);
return new AxiomSoap12Fault(fault, getAxiomFactory());
}
@Override
public Soap12Fault addDataEncodingUnknownFault(QName[] subcodes, String reason, Locale locale) {
Assert.notNull(locale, "No locale given");
SOAPFault fault = addStandardFault(SOAP12Constants.FAULT_CODE_DATA_ENCODING_UNKNOWN, reason, locale);
return new AxiomSoap12Fault(fault, getAxiomFactory());
}
private SOAPFault addStandardFault(String localName, String faultStringOrReason, Locale locale) {
Assert.notNull(faultStringOrReason, "No faultStringOrReason given");
try {
AxiomUtils.removeContents(getAxiomBody());
SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody());
SOAPFaultCode code = getAxiomFactory().createSOAPFaultCode(fault);
SOAPFaultValue value = getAxiomFactory().createSOAPFaultValue(code);
value.setText(fault.getNamespace().getPrefix() + ":" + localName);
SOAPFaultReason reason = getAxiomFactory().createSOAPFaultReason(fault);
SOAPFaultText text = getAxiomFactory().createSOAPFaultText(reason);
if (locale != null) {
text.setLang(AxiomUtils.toLanguage(locale));
}
text.setText(faultStringOrReason);
return fault;
} catch (SOAPProcessingException ex) {
throw new AxiomSoapFaultException(ex);
}
}
@Override
public Soap12Fault getFault() {
SOAPFault axiomFault = getAxiomBody().getFault();
return axiomFault != null ? new AxiomSoap12Fault(axiomFault, getAxiomFactory()) : null;
}
}

View File

@@ -1,148 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultCode;
import org.apache.axiom.soap.SOAPFaultNode;
import org.apache.axiom.soap.SOAPFaultReason;
import org.apache.axiom.soap.SOAPFaultSubCode;
import org.apache.axiom.soap.SOAPFaultText;
import org.apache.axiom.soap.SOAPFaultValue;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.axiom.support.AxiomUtils;
import org.springframework.ws.soap.soap12.Soap12Fault;
/** Axiom-specific version of {@code org.springframework.ws.soap.Soap12Fault}. */
class AxiomSoap12Fault extends AxiomSoapFault implements Soap12Fault {
AxiomSoap12Fault(SOAPFault axiomFault, SOAPFactory axiomFactory) {
super(axiomFault, axiomFactory);
}
@Override
public QName getFaultCode() {
return getAxiomFault().getCode().getValue().getTextAsQName();
}
@Override
public Iterator<QName> getFaultSubcodes() {
List<QName> subcodes = new ArrayList<QName>();
SOAPFaultSubCode subcode = getAxiomFault().getCode().getSubCode();
while (subcode != null) {
subcodes.add(subcode.getValue().getTextAsQName());
subcode = subcode.getSubCode();
}
return subcodes.iterator();
}
@Override
public void addFaultSubcode(QName subcode) {
SOAPFaultCode faultCode = getAxiomFault().getCode();
SOAPFaultSubCode faultSubCode = null;
if (faultCode.getSubCode() == null) {
faultSubCode = getAxiomFactory().createSOAPFaultSubCode(faultCode);
} else {
faultSubCode = faultCode.getSubCode();
while (true) {
if (faultSubCode.getSubCode() != null) {
faultSubCode = faultSubCode.getSubCode();
} else {
faultSubCode = getAxiomFactory().createSOAPFaultSubCode(faultSubCode);
break;
}
}
}
SOAPFaultValue faultValue = getAxiomFactory().createSOAPFaultValue(faultSubCode);
setValueText(subcode, faultValue);
}
private void setValueText(QName code, SOAPFaultValue faultValue) {
String prefix = code.getPrefix();
if (StringUtils.hasLength(code.getNamespaceURI()) && StringUtils.hasLength(prefix)) {
OMNamespace namespace = getAxiomFault().findNamespaceURI(prefix);
if (namespace == null) {
getAxiomFault().declareNamespace(code.getNamespaceURI(), prefix);
}
} else if (StringUtils.hasLength(code.getNamespaceURI())) {
OMNamespace namespace = getAxiomFault().findNamespace(code.getNamespaceURI(), null);
if (namespace == null) {
throw new IllegalArgumentException("Could not resolve namespace of code [" + code + "]");
}
code = new QName(code.getNamespaceURI(), code.getLocalPart(), namespace.getPrefix());
}
faultValue.setText(prefix + ":" + code.getLocalPart());
}
@Override
public String getFaultNode() {
SOAPFaultNode faultNode = getAxiomFault().getNode();
if (faultNode == null) {
return null;
} else {
return faultNode.getFaultNodeValue();
}
}
@Override
public void setFaultNode(String uri) {
try {
SOAPFaultNode faultNode = getAxiomFactory().createSOAPFaultNode(getAxiomFault());
faultNode.setFaultNodeValue(uri);
getAxiomFault().setNode(faultNode);
} catch (SOAPProcessingException ex) {
throw new AxiomSoapFaultException(ex);
}
}
@Override
public String getFaultStringOrReason() {
return getFaultReasonText(Locale.getDefault());
}
@Override
public String getFaultReasonText(Locale locale) {
SOAPFaultReason faultReason = getAxiomFault().getReason();
String language = AxiomUtils.toLanguage(locale);
SOAPFaultText faultText = faultReason.getSOAPFaultText(language);
return faultText != null ? faultText.getText() : null;
}
@Override
public void setFaultReasonText(Locale locale, String text) {
SOAPFaultReason faultReason = getAxiomFault().getReason();
String language = AxiomUtils.toLanguage(locale);
try {
SOAPFaultText faultText = getAxiomFactory().createSOAPFaultText(faultReason);
faultText.setLang(language);
faultText.setText(text);
} catch (SOAPProcessingException ex) {
throw new AxiomSoapFaultException(ex);
}
}
}

View File

@@ -1,99 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.RolePlayer;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.util.ObjectUtils;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.ws.soap.soap12.Soap12Header;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.Soap12Header}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoap12Header extends AxiomSoapHeader implements Soap12Header {
AxiomSoap12Header(SOAPHeader axiomHeader, SOAPFactory axiomFactory) {
super(axiomHeader, axiomFactory);
}
@Override
public SoapHeaderElement addNotUnderstoodHeaderElement(QName headerName) {
try {
SOAPHeaderBlock notUnderstood = getAxiomHeader().addHeaderBlock("NotUnderstood", getAxiomHeader().getNamespace());
OMNamespace headerNamespace = notUnderstood.declareNamespace(headerName.getNamespaceURI(),
headerName.getPrefix());
notUnderstood.addAttribute("qname", headerNamespace.getPrefix() + ":" + headerName.getLocalPart(), null);
return new AxiomSoapHeaderElement(notUnderstood, getAxiomFactory());
} catch (SOAPProcessingException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
public SoapHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris) {
try {
SOAPHeaderBlock upgrade = getAxiomHeader().addHeaderBlock("Upgrade", getAxiomHeader().getNamespace());
for (String supportedSoapUri : supportedSoapUris) {
OMElement supportedEnvelope = getAxiomFactory().createOMElement("SupportedEnvelope",
getAxiomHeader().getNamespace(), upgrade);
OMNamespace namespace = supportedEnvelope.declareNamespace(supportedSoapUri, "");
supportedEnvelope.addAttribute("qname", namespace.getPrefix() + ":Envelope", null);
}
return new AxiomSoapHeaderElement(upgrade, getAxiomFactory());
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineHeaderElementsToProcess(final String[] roles,
final boolean isUltimateDestination) throws SoapHeaderException {
RolePlayer rolePlayer = null;
if (!ObjectUtils.isEmpty(roles)) {
rolePlayer = new RolePlayer() {
public List<?> getRoles() {
return Arrays.asList(roles);
}
public boolean isUltimateDestination() {
return isUltimateDestination;
}
};
}
Iterator<SOAPHeaderBlock> result = (Iterator<SOAPHeaderBlock>) getAxiomHeader().getHeadersToProcess(rolePlayer);
return new AxiomSoapHeaderElementIterator(result);
}
}

View File

@@ -1,83 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFactory;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.axiom.support.AxiomUtils;
import org.springframework.ws.stream.StreamingPayload;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.Soap11Body}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
abstract class AxiomSoapBody extends AxiomSoapElement implements SoapBody {
private final Payload payload;
protected AxiomSoapBody(SOAPBody axiomBody, SOAPFactory axiomFactory, boolean payloadCaching) {
super(axiomBody, axiomFactory);
if (payloadCaching) {
payload = new CachingPayload(axiomBody, axiomFactory);
} else {
payload = new NonCachingPayload(axiomBody, axiomFactory);
}
}
@Override
public Source getPayloadSource() {
return payload.getSource();
}
@Override
public Result getPayloadResult() {
return payload.getResult();
}
@Override
public boolean hasFault() {
return getAxiomBody().hasFault();
}
protected final SOAPBody getAxiomBody() {
return (SOAPBody) getAxiomElement();
}
public void setStreamingPayload(StreamingPayload payload) {
Assert.notNull(payload, "'payload' must not be null");
OMDataSource dataSource = new StreamingOMDataSource(payload);
SOAPFactory factory = getAxiomFactory();
QName name = payload.getName();
// Ignore the prefix; only the namespace URI and local name are significant
OMElement payloadElement = factory.createOMElement(dataSource, name.getLocalPart(),
factory.createOMNamespace(name.getNamespaceURI(), null));
SOAPBody soapBody = getAxiomBody();
AxiomUtils.removeContents(soapBody);
soapBody.addChild(payloadElement);
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.soap.SoapEnvelopeException;
/**
* @author Arjen Poutsma
* @since 1.0.0
*/
@SuppressWarnings("serial")
public class AxiomSoapBodyException extends SoapEnvelopeException {
public AxiomSoapBodyException(String msg) {
super(msg);
}
public AxiomSoapBodyException(String msg, Throwable ex) {
super(msg, ex);
}
public AxiomSoapBodyException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,145 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAPFactory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.StaxUtils;
import org.springframework.ws.soap.SoapElement;
/**
* Axiom-specific version of {@link SoapElement}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoapElement implements SoapElement {
private final OMElement axiomElement;
private final SOAPFactory axiomFactory;
protected AxiomSoapElement(OMElement axiomElement, SOAPFactory axiomFactory) {
Assert.notNull(axiomElement, "axiomElement must not be null");
Assert.notNull(axiomFactory, "axiomFactory must not be null");
this.axiomElement = axiomElement;
this.axiomFactory = axiomFactory;
}
@Override
public final QName getName() {
try {
return axiomElement.getQName();
} catch (OMException ex) {
throw new AxiomSoapElementException(ex);
}
}
@Override
public final Source getSource() {
try {
return StaxUtils.createCustomStaxSource(axiomElement.getXMLStreamReader());
} catch (OMException ex) {
throw new AxiomSoapElementException(ex);
}
}
@Override
public final void addAttribute(QName name, String value) {
try {
String namespaceUri = name.getNamespaceURI();
String prefix = name.getPrefix();
if (StringUtils.hasLength(namespaceUri) && !StringUtils.hasLength(prefix)) {
prefix = null;
}
OMNamespace namespace = getAxiomFactory().createOMNamespace(namespaceUri, prefix);
OMAttribute attribute = getAxiomFactory().createOMAttribute(name.getLocalPart(), namespace, value);
getAxiomElement().addAttribute(attribute);
} catch (OMException ex) {
throw new AxiomSoapElementException(ex);
}
}
@Override
public void removeAttribute(QName name) {
try {
OMAttribute attribute = getAxiomElement().getAttribute(name);
if (attribute != null) {
getAxiomElement().removeAttribute(attribute);
}
} catch (OMException ex) {
throw new AxiomSoapElementException(ex);
}
}
@Override
public final String getAttributeValue(QName name) {
try {
return getAxiomElement().getAttributeValue(name);
} catch (OMException ex) {
throw new AxiomSoapElementException(ex);
}
}
@Override
public final Iterator<QName> getAllAttributes() {
try {
List<QName> results = new ArrayList<QName>();
for (Iterator<?> iterator = getAxiomElement().getAllAttributes(); iterator.hasNext();) {
OMAttribute attribute = (OMAttribute) iterator.next();
results.add(attribute.getQName());
}
return results.iterator();
} catch (OMException ex) {
throw new AxiomSoapElementException(ex);
}
}
@Override
public void addNamespaceDeclaration(String prefix, String namespaceUri) {
try {
if (StringUtils.hasLength(prefix)) {
getAxiomElement().declareNamespace(namespaceUri, prefix);
} else {
getAxiomElement().declareDefaultNamespace(namespaceUri);
}
} catch (OMException ex) {
throw new AxiomSoapElementException(ex);
}
}
protected final OMElement getAxiomElement() {
return axiomElement;
}
protected final SOAPFactory getAxiomFactory() {
return axiomFactory;
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.soap.SoapElementException;
@SuppressWarnings("serial")
public class AxiomSoapElementException extends SoapElementException {
public AxiomSoapElementException(String msg) {
super(msg);
}
public AxiomSoapElementException(String msg, Throwable ex) {
super(msg, ex);
}
public AxiomSoapElementException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPHeader;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapHeader;
/**
* Axiom-Specific version of {@code org.springframework.ws.soap.SoapEnvelope}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoapEnvelope extends AxiomSoapElement implements SoapEnvelope {
boolean payloadCaching;
private AxiomSoapBody body;
private final boolean langAttributeOnSoap11FaultString;
AxiomSoapEnvelope(SOAPEnvelope axiomEnvelope, SOAPFactory axiomFactory, boolean payloadCaching,
boolean langAttributeOnSoap11FaultString) {
super(axiomEnvelope, axiomFactory);
this.payloadCaching = payloadCaching;
this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
}
@Override
public SoapHeader getHeader() {
try {
if (getAxiomEnvelope().getHeader() == null) {
return null;
} else {
SOAPHeader axiomHeader = getAxiomEnvelope().getHeader();
String namespaceURI = getAxiomEnvelope().getNamespace().getNamespaceURI();
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
return new AxiomSoap11Header(axiomHeader, getAxiomFactory());
} else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
return new AxiomSoap12Header(axiomHeader, getAxiomFactory());
} else {
throw new AxiomSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\"");
}
}
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
public SoapBody getBody() {
if (body == null) {
try {
SOAPBody axiomBody = getAxiomEnvelope().getBody();
String namespaceURI = getAxiomEnvelope().getNamespace().getNamespaceURI();
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
body = new AxiomSoap11Body(axiomBody, getAxiomFactory(), payloadCaching, langAttributeOnSoap11FaultString);
} else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(namespaceURI)) {
body = new AxiomSoap12Body(axiomBody, getAxiomFactory(), payloadCaching);
} else {
throw new AxiomSoapEnvelopeException("Unknown SOAP namespace \"" + namespaceURI + "\"");
}
} catch (OMException ex) {
throw new AxiomSoapBodyException(ex);
}
}
return body;
}
protected SOAPEnvelope getAxiomEnvelope() {
return (SOAPEnvelope) getAxiomElement();
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.soap.SoapEnvelopeException;
/**
* @author Arjen Poutsma
* @since 1.0.0
*/
@SuppressWarnings("serial")
public class AxiomSoapEnvelopeException extends SoapEnvelopeException {
public AxiomSoapEnvelopeException(String msg) {
super(msg);
}
public AxiomSoapEnvelopeException(String msg, Throwable ex) {
super(msg, ex);
}
public AxiomSoapEnvelopeException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,78 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFault;
import org.apache.axiom.soap.SOAPFaultDetail;
import org.apache.axiom.soap.SOAPFaultRole;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapFaultDetail;
/** @author Arjen Poutsma */
abstract class AxiomSoapFault extends AxiomSoapElement implements SoapFault {
protected AxiomSoapFault(SOAPFault axiomFault, SOAPFactory axiomFactory) {
super(axiomFault, axiomFactory);
}
@Override
public String getFaultActorOrRole() {
SOAPFaultRole faultRole = getAxiomFault().getRole();
return faultRole != null ? faultRole.getRoleValue() : null;
}
@Override
public void setFaultActorOrRole(String actor) {
try {
SOAPFaultRole axiomFaultRole = getAxiomFactory().createSOAPFaultRole(getAxiomFault());
axiomFaultRole.setRoleValue(actor);
} catch (SOAPProcessingException ex) {
throw new AxiomSoapFaultException(ex);
}
}
@Override
public SoapFaultDetail getFaultDetail() {
try {
SOAPFaultDetail axiomFaultDetail = getAxiomFault().getDetail();
return axiomFaultDetail != null ? new AxiomSoapFaultDetail(axiomFaultDetail, getAxiomFactory()) : null;
} catch (OMException ex) {
throw new AxiomSoapFaultException(ex);
}
}
@Override
public SoapFaultDetail addFaultDetail() {
try {
SOAPFaultDetail axiomFaultDetail = getAxiomFactory().createSOAPFaultDetail(getAxiomFault());
return new AxiomSoapFaultDetail(axiomFaultDetail, getAxiomFactory());
} catch (OMException ex) {
throw new AxiomSoapFaultException(ex);
}
}
protected SOAPFault getAxiomFault() {
return (SOAPFault) getAxiomElement();
}
}

View File

@@ -1,99 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPFaultDetail;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.SoapFaultDetailElement;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.SoapFaultDetail}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoapFaultDetail extends AxiomSoapElement implements SoapFaultDetail {
public AxiomSoapFaultDetail(SOAPFaultDetail axiomFaultDetail, SOAPFactory axiomFactory) {
super(axiomFaultDetail, axiomFactory);
}
@Override
public SoapFaultDetailElement addFaultDetailElement(QName name) {
try {
OMElement element = getAxiomFactory().createOMElement(name, getAxiomFaultDetail());
return new AxiomSoapFaultDetailElement(element, getAxiomFactory());
} catch (OMException ex) {
throw new AxiomSoapFaultException(ex);
}
}
@Override
@SuppressWarnings("unchecked")
public Iterator<SoapFaultDetailElement> getDetailEntries() {
return new AxiomSoapFaultDetailElementIterator(getAxiomFaultDetail().getChildElements());
}
@Override
public Result getResult() {
return getAxiomFaultDetail().getSAXResult();
}
protected SOAPFaultDetail getAxiomFaultDetail() {
return (SOAPFaultDetail) getAxiomElement();
}
private class AxiomSoapFaultDetailElementIterator implements Iterator<SoapFaultDetailElement> {
private final Iterator<OMElement> axiomIterator;
private AxiomSoapFaultDetailElementIterator(Iterator<OMElement> axiomIterator) {
this.axiomIterator = axiomIterator;
}
@Override
public boolean hasNext() {
return axiomIterator.hasNext();
}
@Override
public SoapFaultDetailElement next() {
try {
OMElement axiomElement = axiomIterator.next();
return new AxiomSoapFaultDetailElement(axiomElement, getAxiomFactory());
} catch (OMException ex) {
throw new AxiomSoapFaultException(ex);
}
}
@Override
public void remove() {
axiomIterator.remove();
}
}
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import javax.xml.transform.Result;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAPFactory;
import org.springframework.ws.soap.SoapFaultDetailElement;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.SoapFaultDetailElement}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
class AxiomSoapFaultDetailElement extends AxiomSoapElement implements SoapFaultDetailElement {
public AxiomSoapFaultDetailElement(OMElement axiomElement, SOAPFactory soapFactory) {
super(axiomElement, soapFactory);
}
@Override
public Result getResult() {
try {
return getAxiomElement().getSAXResult();
} catch (OMException ex) {
throw new AxiomSoapFaultException(ex);
}
}
@Override
public void addText(String text) {
try {
getAxiomElement().setText(text);
} catch (OMException ex) {
throw new AxiomSoapFaultException(ex);
}
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.soap.SoapFaultException;
/**
* @author Arjen Poutsma
* @since 1.0.0
*/
@SuppressWarnings("serial")
public class AxiomSoapFaultException extends SoapFaultException {
public AxiomSoapFaultException(String msg) {
super(msg);
}
public AxiomSoapFaultException(String msg, Throwable ex) {
super(msg, ex);
}
public AxiomSoapFaultException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,136 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
/**
* Axiom-specific version of {@code org.springframework.ws.soap.SoapHeader}.
*
* @author Arjen Poutsma
* @since 1.0.0
*/
abstract class AxiomSoapHeader extends AxiomSoapElement implements SoapHeader {
AxiomSoapHeader(SOAPHeader axiomHeader, SOAPFactory axiomFactory) {
super(axiomHeader, axiomFactory);
}
@Override
public Result getResult() {
return getAxiomHeader().getSAXResult();
}
@Override
public SoapHeaderElement addHeaderElement(QName name) {
try {
OMNamespace namespace = getAxiomFactory().createOMNamespace(name.getNamespaceURI(), name.getPrefix());
SOAPHeaderBlock axiomHeaderBlock = getAxiomHeader().addHeaderBlock(name.getLocalPart(), namespace);
return new AxiomSoapHeaderElement(axiomHeaderBlock, getAxiomFactory());
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
public void removeHeaderElement(QName name) throws SoapHeaderException {
try {
OMElement element = getAxiomHeader().getFirstChildWithName(name);
if (element != null) {
element.detach();
}
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineMustUnderstandHeaderElements(String role) {
try {
return new AxiomSoapHeaderElementIterator(getAxiomHeader().examineMustUnderstandHeaderBlocks(role));
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineAllHeaderElements() {
try {
return new AxiomSoapHeaderElementIterator(getAxiomHeader().examineAllHeaderBlocks());
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
@SuppressWarnings("unchecked")
public Iterator<SoapHeaderElement> examineHeaderElements(QName name) throws SoapHeaderException {
try {
return new AxiomSoapHeaderElementIterator(getAxiomHeader().getChildrenWithName(name));
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
protected SOAPHeader getAxiomHeader() {
return (SOAPHeader) getAxiomElement();
}
protected class AxiomSoapHeaderElementIterator implements Iterator<SoapHeaderElement> {
private final Iterator<? extends OMElement> axiomIterator;
protected AxiomSoapHeaderElementIterator(Iterator<? extends OMElement> axiomIterator) {
this.axiomIterator = axiomIterator;
}
@Override
public boolean hasNext() {
return axiomIterator.hasNext();
}
@Override
public SoapHeaderElement next() {
try {
OMElement axiomHeaderBlock = axiomIterator.next();
return new AxiomSoapHeaderElement(axiomHeaderBlock, getAxiomFactory());
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
public void remove() {
axiomIterator.remove();
}
}
}

View File

@@ -1,78 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import javax.xml.transform.Result;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPHeaderBlock;
import org.springframework.ws.soap.SoapHeaderElement;
/** Axiom-specific version of {@code org.springframework.ws.soap.SoapHeaderHeaderElement}. */
class AxiomSoapHeaderElement extends AxiomSoapElement implements SoapHeaderElement {
public AxiomSoapHeaderElement(OMElement axiomHeaderBlock, SOAPFactory axiomFactory) {
super(axiomHeaderBlock, axiomFactory);
}
@Override
public String getActorOrRole() {
return getAxiomHeaderBlock().getRole();
}
@Override
public void setActorOrRole(String role) {
getAxiomHeaderBlock().setRole(role);
}
@Override
public boolean getMustUnderstand() {
return getAxiomHeaderBlock().getMustUnderstand();
}
@Override
public void setMustUnderstand(boolean mustUnderstand) {
getAxiomHeaderBlock().setMustUnderstand(mustUnderstand);
}
@Override
public Result getResult() {
try {
return getAxiomHeaderBlock().getSAXResult();
} catch (OMException ex) {
throw new AxiomSoapHeaderException(ex);
}
}
@Override
public String getText() {
return getAxiomHeaderBlock().getText();
}
@Override
public void setText(String content) {
getAxiomHeaderBlock().setText(content);
}
protected SOAPHeaderBlock getAxiomHeaderBlock() {
return (SOAPHeaderBlock) getAxiomElement();
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.soap.SoapHeaderException;
/**
* @author Arjen Poutsma
* @since 1.0.0
*/
@SuppressWarnings("serial")
public class AxiomSoapHeaderException extends SoapHeaderException {
public AxiomSoapHeaderException(String msg) {
super(msg);
}
public AxiomSoapHeaderException(String msg, Throwable ex) {
super(msg, ex);
}
public AxiomSoapHeaderException(Throwable ex) {
super(ex);
}
}

View File

@@ -1,393 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.util.Iterator;
import javax.activation.DataHandler;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMSource;
import org.apache.axiom.attachments.Attachments;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.impl.MTOMConstants;
import org.apache.axiom.om.impl.OMMultipartWriter;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.soap.SOAPProcessingException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.mime.Attachment;
import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.axiom.support.AxiomUtils;
import org.springframework.ws.soap.support.SoapUtils;
import org.springframework.ws.stream.StreamingPayload;
import org.springframework.ws.stream.StreamingWebServiceMessage;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportOutputStream;
import org.w3c.dom.Document;
/**
* AXIOM-specific implementation of the {@link SoapMessage} interface. Created via the {@link AxiomSoapMessageFactory},
* wraps a {@link SOAPMessage}.
*
* @author Arjen Poutsma
* @see SOAPMessage
* @since 1.0.0
*/
public class AxiomSoapMessage extends AbstractSoapMessage implements StreamingWebServiceMessage {
private static final String EMPTY_SOAP_ACTION = "\"\"";
private SOAPMessage axiomMessage;
private final SOAPFactory axiomFactory;
private final Attachments attachments;
private final boolean payloadCaching;
private AxiomSoapEnvelope envelope;
private String soapAction;
private final boolean langAttributeOnSoap11FaultString;
private OMOutputFormat outputFormat;
/**
* Create a new, empty {@code AxiomSoapMessage}.
*
* @param soapFactory the AXIOM SOAPFactory
*/
public AxiomSoapMessage(SOAPFactory soapFactory) {
this(soapFactory, true, true);
}
/**
* Create a new, empty {@code AxiomSoapMessage}.
*
* @param soapFactory the AXIOM SOAPFactory
*/
public AxiomSoapMessage(SOAPFactory soapFactory, boolean payloadCaching, boolean langAttributeOnSoap11FaultString) {
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
axiomFactory = soapFactory;
axiomMessage = axiomFactory.createSOAPMessage();
axiomMessage.setSOAPEnvelope(soapEnvelope);
attachments = new Attachments();
this.payloadCaching = payloadCaching;
this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
soapAction = EMPTY_SOAP_ACTION;
}
/**
* Create a new {@code AxiomSoapMessage} based on the given AXIOM {@code SOAPMessage}.
*
* @param soapMessage the AXIOM SOAPMessage
* @param soapAction the value of the SOAP Action header
* @param payloadCaching whether the contents of the SOAP body should be cached or not
*/
public AxiomSoapMessage(SOAPMessage soapMessage, String soapAction, boolean payloadCaching,
boolean langAttributeOnSoap11FaultString) {
this(soapMessage, new Attachments(), soapAction, payloadCaching, langAttributeOnSoap11FaultString);
}
/**
* Create a new {@code AxiomSoapMessage} based on the given AXIOM {@code SOAPMessage} and attachments.
*
* @param soapMessage the AXIOM SOAPMessage
* @param attachments the attachments
* @param soapAction the value of the SOAP Action header
* @param payloadCaching whether the contents of the SOAP body should be cached or not
*/
public AxiomSoapMessage(SOAPMessage soapMessage, Attachments attachments, String soapAction, boolean payloadCaching,
boolean langAttributeOnSoap11FaultString) {
Assert.notNull(soapMessage, "'soapMessage' must not be null");
Assert.notNull(attachments, "'attachments' must not be null");
axiomMessage = soapMessage;
axiomFactory = (SOAPFactory) soapMessage.getSOAPEnvelope().getOMFactory();
this.attachments = attachments;
if (!StringUtils.hasLength(soapAction)) {
soapAction = EMPTY_SOAP_ACTION;
}
this.soapAction = soapAction;
this.payloadCaching = payloadCaching;
this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
}
/** Return the AXIOM {@code SOAPMessage} that this {@code AxiomSoapMessage} is based on. */
public final SOAPMessage getAxiomMessage() {
return axiomMessage;
}
/**
* Sets the AXIOM {@code SOAPMessage} that this {@code AxiomSoapMessage} is based on.
* <p>
* Calling this method also clears the SOAP Action property.
*/
public final void setAxiomMessage(SOAPMessage axiomMessage) {
Assert.notNull(axiomMessage, "'axiomMessage' must not be null");
this.axiomMessage = axiomMessage;
this.envelope = null;
this.soapAction = EMPTY_SOAP_ACTION;
}
/**
* Sets the {@link OMOutputFormat} to be used when writing the message.
*
* @see #writeTo(java.io.OutputStream)
*/
public void setOutputFormat(OMOutputFormat outputFormat) {
this.outputFormat = outputFormat;
}
@Override
public void setStreamingPayload(StreamingPayload payload) {
AxiomSoapBody soapBody = (AxiomSoapBody) getSoapBody();
soapBody.setStreamingPayload(payload);
}
@Override
public SoapEnvelope getEnvelope() {
if (envelope == null) {
try {
envelope = new AxiomSoapEnvelope(axiomMessage.getSOAPEnvelope(), axiomFactory, payloadCaching,
langAttributeOnSoap11FaultString);
} catch (SOAPProcessingException ex) {
throw new AxiomSoapEnvelopeException(ex);
}
}
return envelope;
}
@Override
public String getSoapAction() {
return soapAction;
}
@Override
public void setSoapAction(String soapAction) {
soapAction = SoapUtils.escapeAction(soapAction);
this.soapAction = soapAction;
}
@Override
public Document getDocument() {
return AxiomUtils.toDocument(axiomMessage.getSOAPEnvelope());
}
@Override
public void setDocument(Document document) {
// save the Soap Action
String soapAction = getSoapAction();
// replace the Axiom message
setAxiomMessage(OMXMLBuilderFactory.createSOAPModelBuilder(axiomFactory.getMetaFactory(), new DOMSource(document))
.getSOAPMessage());
// restore the Soap Action
setSoapAction(soapAction);
}
@Override
public boolean isXopPackage() {
try {
return MTOMConstants.MTOM_TYPE.equals(attachments.getAttachmentSpecType());
} catch (OMException ex) {
return false;
} catch (NullPointerException ex) {
// gotta love Axis2
return false;
}
}
@Override
public boolean convertToXopPackage() {
return false;
}
@Override
public Attachment getAttachment(String contentId) {
Assert.hasLength(contentId, "contentId must not be empty");
if (contentId.startsWith("<") && contentId.endsWith(">")) {
contentId = contentId.substring(1, contentId.length() - 1);
}
DataHandler dataHandler = attachments.getDataHandler(contentId);
return dataHandler != null ? new AxiomAttachment(contentId, dataHandler) : null;
}
@Override
public Iterator<Attachment> getAttachments() {
return new AxiomAttachmentIterator();
}
@Override
public Attachment addAttachment(String contentId, DataHandler dataHandler) {
Assert.hasLength(contentId, "contentId must not be empty");
Assert.notNull(dataHandler, "dataHandler must not be null");
attachments.addDataHandler(contentId, dataHandler);
return new AxiomAttachment(contentId, dataHandler);
}
@Override
public void writeTo(OutputStream outputStream) throws IOException {
try {
OMOutputFormat outputFormat = getOutputFormat();
if (outputStream instanceof TransportOutputStream) {
TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream;
String contentType = outputFormat.getContentType();
if (!(outputFormat.isDoingSWA() || outputFormat.isOptimized())) {
String charsetEncoding = axiomMessage.getCharsetEncoding();
contentType += "; charset=" + charsetEncoding;
}
SoapVersion version = getVersion();
if (SoapVersion.SOAP_11 == version) {
transportOutputStream.addHeader(TransportConstants.HEADER_SOAP_ACTION, soapAction);
transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType());
} else if (SoapVersion.SOAP_12 == version) {
contentType += "; action=" + soapAction;
transportOutputStream.addHeader(TransportConstants.HEADER_ACCEPT, version.getContentType());
}
transportOutputStream.addHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType);
}
if (!(outputFormat.isOptimized()) & outputFormat.isDoingSWA()) {
writeSwAMessage(outputStream, outputFormat);
} else {
if (payloadCaching) {
axiomMessage.serialize(outputStream, outputFormat);
} else {
axiomMessage.serializeAndConsume(outputStream, outputFormat);
}
}
outputStream.flush();
} catch (XMLStreamException ex) {
throw new AxiomSoapMessageException("Could not write message to OutputStream: " + ex.getMessage(), ex);
} catch (OMException ex) {
throw new AxiomSoapMessageException("Could not write message to OutputStream: " + ex.getMessage(), ex);
}
}
private OMOutputFormat getOutputFormat() {
if (outputFormat != null) {
return outputFormat;
} else {
String charsetEncoding = axiomMessage.getCharsetEncoding();
OMOutputFormat outputFormat = new OMOutputFormat();
outputFormat.setCharSetEncoding(charsetEncoding);
outputFormat.setSOAP11(getVersion() == SoapVersion.SOAP_11);
if (isXopPackage()) {
outputFormat.setDoOptimize(true);
} else if (!attachments.getContentIDSet().isEmpty()) {
outputFormat.setDoingSWA(true);
}
return outputFormat;
}
}
private void writeSwAMessage(OutputStream outputStream, OMOutputFormat format)
throws XMLStreamException, UnsupportedEncodingException {
StringWriter writer = new StringWriter();
SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope();
if (payloadCaching) {
envelope.serialize(writer, format);
} else {
envelope.serializeAndConsume(writer, format);
}
try {
OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format);
Writer rootPartWriter = new OutputStreamWriter(mpw.writeRootPart(), format.getCharSetEncoding());
rootPartWriter.write(writer.toString());
rootPartWriter.close();
// Get the collection of ids associated with the attachments
for (String id : attachments.getAllContentIDs()) {
mpw.writePart(attachments.getDataHandler(id), id);
}
mpw.complete();
} catch (IOException ex) {
throw new OMException("Error writing SwA message", ex);
}
}
public String toString() {
StringBuilder builder = new StringBuilder("AxiomSoapMessage");
if (payloadCaching) {
try {
SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope();
if (envelope != null) {
SOAPBody body = envelope.getBody();
if (body != null) {
OMElement bodyElement = body.getFirstElement();
if (bodyElement != null) {
builder.append(' ');
builder.append(bodyElement.getQName());
}
}
}
} catch (OMException ex) {
// ignore
}
}
return builder.toString();
}
private class AxiomAttachmentIterator implements Iterator<Attachment> {
private final Iterator<String> iterator;
@SuppressWarnings("unchecked")
private AxiomAttachmentIterator() {
iterator = attachments.getContentIDSet().iterator();
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public Attachment next() {
String contentId = iterator.next();
DataHandler dataHandler = attachments.getDataHandler(contentId);
return new AxiomAttachment(contentId, dataHandler);
}
@Override
public void remove() {
iterator.remove();
}
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.soap.SoapMessageCreationException;
/**
* @author Arjen Poutsma
* @since 1.0.0
*/
@SuppressWarnings("serial")
public class AxiomSoapMessageCreationException extends SoapMessageCreationException {
public AxiomSoapMessageCreationException(String msg) {
super(msg);
}
public AxiomSoapMessageCreationException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import org.springframework.ws.soap.SoapMessageException;
/**
* @author Arjen Poutsma
* @since 1.0.0
*/
@SuppressWarnings("serial")
public class AxiomSoapMessageException extends SoapMessageException {
public AxiomSoapMessageException(String msg) {
super(msg);
}
public AxiomSoapMessageException(String msg, Throwable ex) {
super(msg, ex);
}
}

View File

@@ -1,380 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Locale;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.apache.axiom.attachments.Attachments;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.impl.MTOMConstants;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axiom.soap.SOAP11Version;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAP12Version;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPMessage;
import org.apache.axiom.soap.SOAPModelBuilder;
import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor;
import org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping;
import org.springframework.ws.soap.support.SoapUtils;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportInputStream;
import org.springframework.xml.XMLInputFactoryUtils;
/**
* Axiom-specific implementation of the {@link org.springframework.ws.WebServiceMessageFactory WebServiceMessageFactory}
* interface. Creates {@link org.springframework.ws.soap.axiom.AxiomSoapMessage AxiomSoapMessages}.
* <p>
* To increase reading performance on the SOAP request created by this message factory, you can set the
* {@link #setPayloadCaching(boolean) payloadCaching} property to {@code false} (default is {@code true}). This this
* will read the contents of the body directly from the stream. However, <strong>when this setting is enabled, the
* payload can only be read once</strong>. This means that any endpoint mappings or interceptors which are based on the
* message payload (such as the {@link PayloadRootAnnotationMethodEndpointMapping}, the
* {@link PayloadValidatingInterceptor}, or the {@link PayloadLoggingInterceptor}) cannot be used. Instead, use an
* endpoint mapping that does not consume the payload (i.e. the {@link SoapActionAnnotationMethodEndpointMapping}).
* <p>
* Additionally, this message factory can cache large attachments to disk by setting the
* {@link #setAttachmentCaching(boolean) attachmentCaching} property to {@code true} (default is {@code false}).
* Optionally, the location where attachments are stored can be defined via the {@link #setAttachmentCacheDir(File)
* attachmentCacheDir} property (defaults to the system temp file path).
* <p>
* Mostly derived from {@code org.apache.axis2.transport.http.HTTPTransportUtils} and
* {@code org.apache.axis2.transport.TransportUtils}, which we cannot use since they are not part of the Axiom
* distribution.
*
* @author Arjen Poutsma
* @author Andreas Veithen
* @see AxiomSoapMessage
* @see #setPayloadCaching(boolean)
* @since 1.0.0
*/
public class AxiomSoapMessageFactory implements SoapMessageFactory, InitializingBean {
private static final String CHARSET_PARAMETER = "charset";
private static final String DEFAULT_CHARSET_ENCODING = "UTF-8";
private static final String MULTI_PART_RELATED_CONTENT_TYPE = "multipart/related";
private static final Log logger = LogFactory.getLog(AxiomSoapMessageFactory.class);
private XMLInputFactory inputFactory;
private boolean payloadCaching = true;
private boolean attachmentCaching = false;
private File attachmentCacheDir;
private int attachmentCacheThreshold = 4096;
// use SOAP 1.1 by default
private SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
private boolean langAttributeOnSoap11FaultString = true;
private boolean replacingEntityReferences = false;
private boolean supportingExternalEntities = false;
/**
* Indicates whether the SOAP Body payload should be cached or not. Default is {@code true}.
* <p>
* Setting this to {@code false} will increase performance, but also result in the fact that the message payload can
* only be read once.
*/
public void setPayloadCaching(boolean payloadCaching) {
this.payloadCaching = payloadCaching;
}
/**
* Indicates whether SOAP attachments should be cached or not. Default is {@code false}.
* <p>
* Setting this to {@code true} will cause Axiom to store larger attachments on disk, rather than in memory. This
* decreases memory consumption, but decreases performance.
*/
public void setAttachmentCaching(boolean attachmentCaching) {
this.attachmentCaching = attachmentCaching;
}
/**
* Sets the directory where SOAP attachments will be stored. Only used when {@link #setAttachmentCaching(boolean)
* attachmentCaching} is set to {@code true}.
* <p>
* The parameter should be an existing, writable directory. This property defaults to the temporary directory of the
* operating system (i.e. the value of the {@code java.io.tmpdir} system property).
*/
public void setAttachmentCacheDir(File attachmentCacheDir) {
Assert.notNull(attachmentCacheDir, "'attachmentCacheDir' must not be null");
Assert.isTrue(attachmentCacheDir.isDirectory(), "'attachmentCacheDir' must be a directory");
Assert.isTrue(attachmentCacheDir.canWrite(), "'attachmentCacheDir' must be writable");
this.attachmentCacheDir = attachmentCacheDir;
}
/**
* Sets the threshold for attachments caching, in bytes. Attachments larger than this threshold will be cached in the
* {@link #setAttachmentCacheDir(File) attachment cache directory}. Only used when
* {@link #setAttachmentCaching(boolean) attachmentCaching} is set to {@code true}.
* <p>
* Defaults to 4096 bytes (i.e. 4 kilobytes).
*/
public void setAttachmentCacheThreshold(int attachmentCacheThreshold) {
Assert.isTrue(attachmentCacheThreshold > 0, "'attachmentCacheThreshold' must be larger than 0");
this.attachmentCacheThreshold = attachmentCacheThreshold;
}
@Override
public void setSoapVersion(SoapVersion version) {
if (SoapVersion.SOAP_11 == version) {
soapFactory = OMAbstractFactory.getSOAP11Factory();
} else if (SoapVersion.SOAP_12 == version) {
soapFactory = OMAbstractFactory.getSOAP12Factory();
} else {
throw new IllegalArgumentException(
"Invalid version [" + version + "]. " + "Expected the SOAP_11 or SOAP_12 constant");
}
}
/**
* Defines whether a {@code xml:lang} attribute should be set on SOAP 1.1 {@code <faultstring>} elements.
* <p>
* The default is {@code true}, to comply with WS-I, but this flag can be set to {@code false} to the older W3C SOAP
* 1.1 specification.
*
* @see <a href="http://www.ws-i.org/Profiles/BasicProfile-1.1.html#SOAP_Fault_Language">WS-I Basic Profile 1.1</a>
*/
public void setLangAttributeOnSoap11FaultString(boolean langAttributeOnSoap11FaultString) {
this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
}
/**
* Sets whether internal entity references should be replaced with their replacement text and report them as
* characters.
*
* @see XMLInputFactory#IS_REPLACING_ENTITY_REFERENCES
*/
public void setReplacingEntityReferences(boolean replacingEntityReferences) {
this.replacingEntityReferences = replacingEntityReferences;
}
/**
* Sets whether external parsed entities should be resolved.
*
* @see XMLInputFactory#IS_SUPPORTING_EXTERNAL_ENTITIES
*/
public void setSupportingExternalEntities(boolean supportingExternalEntities) {
this.supportingExternalEntities = supportingExternalEntities;
}
@Override
public void afterPropertiesSet() throws Exception {
if (logger.isInfoEnabled()) {
logger.info(payloadCaching ? "Enabled payload caching" : "Disabled payload caching");
}
if (attachmentCacheDir == null) {
String tempDir = System.getProperty("java.io.tmpdir");
setAttachmentCacheDir(new File(tempDir));
}
inputFactory = createXmlInputFactory();
}
@Override
public AxiomSoapMessage createWebServiceMessage() {
return new AxiomSoapMessage(soapFactory, payloadCaching, langAttributeOnSoap11FaultString);
}
@Override
public AxiomSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException {
Assert.isInstanceOf(TransportInputStream.class, inputStream,
"AxiomSoapMessageFactory requires a TransportInputStream");
if (inputFactory == null) {
inputFactory = createXmlInputFactory();
}
TransportInputStream transportInputStream = (TransportInputStream) inputStream;
String contentType = getHeaderValue(transportInputStream, TransportConstants.HEADER_CONTENT_TYPE);
if (!StringUtils.hasLength(contentType)) {
if (logger.isDebugEnabled()) {
logger.debug("TransportInputStream has no Content-Type header; defaulting to \""
+ soapFactory.getSOAPVersion().getMediaType() + "\"");
}
contentType = soapFactory.getSOAPVersion().getMediaType().toString();
}
String soapAction = getHeaderValue(transportInputStream, TransportConstants.HEADER_SOAP_ACTION);
if (!StringUtils.hasLength(soapAction)) {
soapAction = SoapUtils.extractActionFromContentType(contentType);
}
try {
if (isMultiPartRelated(contentType)) {
return createMultiPartAxiomSoapMessage(inputStream, contentType, soapAction);
} else {
return createAxiomSoapMessage(inputStream, contentType, soapAction);
}
} catch (XMLStreamException ex) {
throw new AxiomSoapMessageCreationException("Could not parse request: " + ex.getMessage(), ex);
} catch (OMException ex) {
throw new AxiomSoapMessageCreationException("Could not create message: " + ex.getMessage(), ex);
}
}
private String getHeaderValue(TransportInputStream transportInputStream, String header) throws IOException {
String contentType = null;
Iterator<String> iterator = transportInputStream.getHeaders(header);
if (iterator.hasNext()) {
contentType = iterator.next();
}
return contentType;
}
private boolean isMultiPartRelated(String contentType) {
contentType = contentType.toLowerCase(Locale.ENGLISH);
return contentType.contains(MULTI_PART_RELATED_CONTENT_TYPE);
}
@SuppressWarnings("deprecation")
/** Creates an AxiomSoapMessage without attachments. */
private AxiomSoapMessage createAxiomSoapMessage(InputStream inputStream, String contentType, String soapAction)
throws XMLStreamException {
XMLStreamReader reader = inputFactory.createXMLStreamReader(inputStream, getCharSetEncoding(contentType));
String envelopeNamespace = getSoapEnvelopeNamespace(contentType);
SOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, soapFactory, envelopeNamespace);
SOAPMessage soapMessage = builder.getSOAPMessage();
return new AxiomSoapMessage(soapMessage, soapAction, payloadCaching, langAttributeOnSoap11FaultString);
}
@SuppressWarnings("deprecation")
/** Creates an AxiomSoapMessage with attachments. */
private AxiomSoapMessage createMultiPartAxiomSoapMessage(InputStream inputStream, String contentType,
String soapAction) throws XMLStreamException {
Attachments attachments = new Attachments(inputStream, contentType, attachmentCaching,
attachmentCacheDir.getAbsolutePath(), Integer.toString(attachmentCacheThreshold));
XMLStreamReader reader = inputFactory.createXMLStreamReader(attachments.getRootPartInputStream(),
getCharSetEncoding(attachments.getRootPartContentType()));
SOAPModelBuilder builder;
String envelopeNamespace = getSoapEnvelopeNamespace(contentType);
if (MTOMConstants.SWA_TYPE.equals(attachments.getAttachmentSpecType())
|| MTOMConstants.SWA_TYPE_12.equals(attachments.getAttachmentSpecType())) {
builder = new StAXSOAPModelBuilder(reader, soapFactory, envelopeNamespace);
} else if (MTOMConstants.MTOM_TYPE.equals(attachments.getAttachmentSpecType())) {
builder = new MTOMStAXSOAPModelBuilder(reader, attachments, envelopeNamespace);
} else {
throw new AxiomSoapMessageCreationException(
"Unknown attachment type: [" + attachments.getAttachmentSpecType() + "]");
}
return new AxiomSoapMessage(builder.getSOAPMessage(), attachments, soapAction, payloadCaching,
langAttributeOnSoap11FaultString);
}
private String getSoapEnvelopeNamespace(String contentType) {
if (contentType.contains(SOAP11Constants.SOAP_11_CONTENT_TYPE)) {
return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
} else if (contentType.contains(SOAP12Constants.SOAP_12_CONTENT_TYPE)) {
return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
} else {
throw new AxiomSoapMessageCreationException("Unknown content type '" + contentType + "'");
}
}
/**
* Returns the character set from the given content type. Mostly copied
*
* @return the character set encoding
*/
protected String getCharSetEncoding(String contentType) {
int charSetIdx = contentType.indexOf(CHARSET_PARAMETER);
if (charSetIdx == -1) {
return DEFAULT_CHARSET_ENCODING;
}
int eqIdx = contentType.indexOf("=", charSetIdx);
int indexOfSemiColon = contentType.indexOf(";", eqIdx);
String value;
if (indexOfSemiColon > 0) {
value = contentType.substring(eqIdx + 1, indexOfSemiColon);
} else {
value = contentType.substring(eqIdx + 1, contentType.length()).trim();
}
if (value.startsWith("\"")) {
value = value.substring(1);
}
if (value.endsWith("\"")) {
return value.substring(0, value.length() - 1);
}
if ("null".equalsIgnoreCase(value)) {
return DEFAULT_CHARSET_ENCODING;
} else {
return value.trim();
}
}
/**
* Create a {@code XMLInputFactory} that this resolver will use to create {@link XMLStreamReader} objects.
* <p>
* Can be overridden in subclasses, adding further initialization of the factory. The resulting factory is cached, so
* this method will only be called once.
* <p>
* By default this method creates a standard {@link XMLInputFactory} and configures it based on the
* {@link #setReplacingEntityReferences(boolean) replacingEntityReferences} and
* {@link #setSupportingExternalEntities(boolean) supportingExternalEntities} properties.
*
* @return the created factory
*/
protected XMLInputFactory createXmlInputFactory() {
XMLInputFactory inputFactory = XMLInputFactoryUtils.newInstance();
inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, replacingEntityReferences);
inputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, supportingExternalEntities);
return inputFactory;
}
public String toString() {
StringBuilder builder = new StringBuilder("AxiomSoapMessageFactory[");
if (soapFactory.getSOAPVersion() == SOAP11Version.getSingleton()) {
builder.append("SOAP 1.1");
} else if (soapFactory.getSOAPVersion() == SOAP12Version.getSingleton()) {
builder.append("SOAP 1.2");
}
builder.append(',');
if (payloadCaching) {
builder.append("PayloadCaching enabled");
} else {
builder.append("PayloadCaching disabled");
}
builder.append(']');
return builder.toString();
}
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Result;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFactory;
/**
* Caching payload in Axiom.
*
* @author Arjen Poutsma
* @since 1.5.2
*/
@SuppressWarnings("Since15")
class CachingPayload extends AbstractPayload {
CachingPayload(SOAPBody axiomBody, SOAPFactory axiomFactory) {
super(axiomBody, axiomFactory);
}
@Override
protected XMLStreamReader getStreamReader(OMElement payloadElement) {
OMXMLStreamReaderConfiguration config = new OMXMLStreamReaderConfiguration();
config.setPreserveNamespaceContext(true);
return payloadElement.getXMLStreamReader(true, config);
}
@Override
public Result getResultInternal() {
return getAxiomBody().getSAXResult();
}
}

View File

@@ -1,291 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import java.io.ByteArrayOutputStream;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Result;
import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.ds.ByteArrayDataSource;
import org.apache.axiom.om.util.StAXUtils;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFactory;
import org.springframework.util.xml.StaxUtils;
/**
* Non-caching payload in Axiom.
*
* @author Jim Cummings
* @author Arjen Poutsma
* @since 1.5.2
*/
class NonCachingPayload extends AbstractPayload {
private static final int BUF_SIZE = 1024;
NonCachingPayload(SOAPBody axiomBody, SOAPFactory axiomFactory) {
super(axiomBody, axiomFactory);
}
@Override
public Result getResultInternal() {
return StaxUtils.createCustomStaxResult(new DelegatingStreamWriter());
}
@Override
protected XMLStreamReader getStreamReader(OMElement payloadElement) {
return payloadElement.getXMLStreamReaderWithoutCaching();
}
private class DelegatingStreamWriter implements XMLStreamWriter {
private final ByteArrayOutputStream baos = new ByteArrayOutputStream(BUF_SIZE);
private final XMLStreamWriter delegate;
private QName name;
private String encoding = "UTF-8";
private int elementDepth = 0;
private boolean payloadAdded = false;
private DelegatingStreamWriter() {
try {
this.delegate = StAXUtils.createXMLStreamWriter(baos);
} catch (XMLStreamException ex) {
throw new AxiomSoapBodyException("Could not determine payload root element", ex);
}
}
@Override
public void writeStartDocument() throws XMLStreamException {
// ignored
}
@Override
public void writeStartDocument(String version) throws XMLStreamException {
// ignored
}
@Override
public void writeStartDocument(String encoding, String version) throws XMLStreamException {
this.encoding = encoding;
}
@Override
public void writeStartElement(String localName) throws XMLStreamException {
if (name == null) {
name = new QName(localName);
}
elementDepth++;
delegate.writeStartElement(localName);
}
@Override
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
if (name == null) {
name = new QName(namespaceURI, localName);
}
elementDepth++;
delegate.writeStartElement(namespaceURI, localName);
}
@Override
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
if (name == null) {
name = new QName(namespaceURI, localName, prefix);
}
elementDepth++;
delegate.writeStartElement(prefix, localName, namespaceURI);
}
@Override
public void writeEndElement() throws XMLStreamException {
elementDepth--;
delegate.writeEndElement();
addPayload();
}
private void addPayload() throws XMLStreamException {
if (elementDepth <= 0 && !payloadAdded) {
delegate.flush();
if (baos.size() > 0) {
byte[] buf = baos.toByteArray();
OMDataSource dataSource = new ByteArrayDataSource(buf, encoding);
OMNamespace namespace = getAxiomFactory().createOMNamespace(name.getNamespaceURI(), name.getPrefix());
OMElement payloadElement = getAxiomFactory().createOMElement(dataSource, name.getLocalPart(), namespace);
getAxiomBody().addChild(payloadElement);
payloadAdded = true;
}
}
}
@Override
public void writeEmptyElement(String localName) throws XMLStreamException {
if (name == null) {
name = new QName(localName);
}
delegate.writeEmptyElement(localName);
addPayload();
}
@Override
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
if (name == null) {
name = new QName(namespaceURI, localName);
}
delegate.writeEmptyElement(namespaceURI, localName);
addPayload();
}
@Override
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
if (name == null) {
name = new QName(namespaceURI, localName, prefix);
}
delegate.writeEmptyElement(prefix, localName, namespaceURI);
addPayload();
}
@Override
public void writeEndDocument() throws XMLStreamException {
elementDepth = 0;
delegate.writeEndDocument();
addPayload();
}
// Delegation
@Override
public void close() throws XMLStreamException {
addPayload();
delegate.close();
}
@Override
public void flush() throws XMLStreamException {
delegate.flush();
}
@Override
public NamespaceContext getNamespaceContext() {
return delegate.getNamespaceContext();
}
@Override
public String getPrefix(String uri) throws XMLStreamException {
return delegate.getPrefix(uri);
}
@Override
public Object getProperty(String name) throws IllegalArgumentException {
return delegate.getProperty(name);
}
@Override
public void setDefaultNamespace(String uri) throws XMLStreamException {
delegate.setDefaultNamespace(uri);
}
@Override
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
delegate.setNamespaceContext(context);
}
@Override
public void setPrefix(String prefix, String uri) throws XMLStreamException {
delegate.setPrefix(prefix, uri);
}
@Override
public void writeAttribute(String localName, String value) throws XMLStreamException {
delegate.writeAttribute(localName, value);
}
@Override
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
delegate.writeAttribute(namespaceURI, localName, value);
}
@Override
public void writeAttribute(String prefix, String namespaceURI, String localName, String value)
throws XMLStreamException {
delegate.writeAttribute(prefix, namespaceURI, localName, value);
}
@Override
public void writeCData(String data) throws XMLStreamException {
delegate.writeCData(data);
}
@Override
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
delegate.writeCharacters(text, start, len);
}
@Override
public void writeCharacters(String text) throws XMLStreamException {
delegate.writeCharacters(text);
}
@Override
public void writeComment(String data) throws XMLStreamException {
delegate.writeComment(data);
}
@Override
public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
delegate.writeDefaultNamespace(namespaceURI);
}
@Override
public void writeDTD(String dtd) throws XMLStreamException {
delegate.writeDTD(dtd);
}
@Override
public void writeEntityRef(String name) throws XMLStreamException {
delegate.writeEntityRef(name);
}
@Override
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
delegate.writeNamespace(prefix, namespaceURI);
}
@Override
public void writeProcessingInstruction(String target) throws XMLStreamException {
delegate.writeProcessingInstruction(target);
}
@Override
public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
delegate.writeProcessingInstruction(target, data);
}
}
}

View File

@@ -1,43 +0,0 @@
/*
* Copyright 2005-2010 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
/**
* Defines the contract for payloads in Axiom.
*
* @author Arjen Poutsma
* @since 1.5.2
*/
abstract class Payload {
/**
* Returns the source of the payload.
*
* @return the source of the payload
*/
public abstract Source getSource();
/**
* Returns the result of the payload.
*
* @return the result of the payload
*/
public abstract Result getResult();
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.apache.axiom.om.OMDataSource;
import org.apache.axiom.om.ds.AbstractPushOMDataSource;
import org.springframework.util.Assert;
import org.springframework.ws.stream.StreamingPayload;
/**
* Implementation of {@link OMDataSource} that wraps a {@link StreamingPayload}.
*
* @author Arjen Poutsma
* @since 2.0
*/
class StreamingOMDataSource extends AbstractPushOMDataSource {
private final StreamingPayload payload;
StreamingOMDataSource(StreamingPayload payload) {
Assert.notNull(payload, "'payload' must not be null");
this.payload = payload;
}
@Override
public boolean isDestructiveWrite() {
return false;
}
@Override
public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException {
payload.writeTo(xmlWriter);
}
}

View File

@@ -1,5 +0,0 @@
<html>
<body>
AXis Object Model (AXIOM) support for Spring-WS' soap message infrastructure.
</body>
</html>

View File

@@ -1,140 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.soap.axiom.support;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Iterator;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
import org.apache.axiom.om.OMContainer;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.soap.SOAPEnvelope;
import org.springframework.util.StringUtils;
import org.springframework.xml.DocumentBuilderFactoryUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Collection of generic utility methods to work with Axiom. Includes conversion from {@code OMNamespace}s to
* {@code QName}s.
*
* @author Arjen Poutsma
* @author Tareq Abed Rabbo
* @see org.apache.axiom.om.OMNamespace
* @see javax.xml.namespace.QName
* @since 1.0.0
*/
@SuppressWarnings("Since15")
public abstract class AxiomUtils {
/**
* Converts a {@code javax.xml.namespace.QName} to a {@code org.apache.axiom.om.OMNamespace}. A {@code OMElement} is
* used to resolve the namespace, or to declare a new one.
*
* @param qName the {@code QName} to convert
* @param resolveElement the element used to resolve the Q
* @return the converted SAAJ Name
* @throws OMException if conversion is unsuccessful
* @throws IllegalArgumentException if {@code qName} is not fully qualified
*/
public static OMNamespace toNamespace(QName qName, OMElement resolveElement) throws OMException {
String prefix = qName.getPrefix();
if (StringUtils.hasLength(qName.getNamespaceURI()) && StringUtils.hasLength(prefix)) {
return resolveElement.declareNamespace(qName.getNamespaceURI(), prefix);
} else if (StringUtils.hasLength(qName.getNamespaceURI())) {
// check for existing namespace, and declare if necessary
return resolveElement.declareNamespace(qName.getNamespaceURI(), "");
} else {
throw new IllegalArgumentException("qName [" + qName + "] does not contain a namespace");
}
}
/**
* Converts the given locale to a {@code xml:lang} string, as used in Axiom Faults.
*
* @param locale the locale
* @return the language string
*/
public static String toLanguage(Locale locale) {
return locale.toString().replace('_', '-');
}
/**
* Converts the given locale to a {@code xml:lang} string, as used in Axiom Faults.
*
* @param language the language string
* @return the locale
*/
public static Locale toLocale(String language) {
language = language.replace('-', '_');
return StringUtils.parseLocaleString(language);
}
/** Removes the contents (i.e. children) of the container. */
public static void removeContents(OMContainer container) {
for (Iterator<?> iterator = container.getChildren(); iterator.hasNext();) {
iterator.next();
iterator.remove();
}
}
/**
* Converts a given AXIOM {@link org.apache.axiom.soap.SOAPEnvelope} to a {@link Document}.
*
* @param envelope the SOAP envelope to be converted
* @return the converted document
* @throws IllegalArgumentException in case of errors
*/
public static Document toDocument(SOAPEnvelope envelope) {
try {
if (envelope instanceof Element) {
return ((Element) envelope).getOwnerDocument();
} else {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
envelope.build();
envelope.serialize(bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance();
documentBuilderFactory.setNamespaceAware(true);
return documentBuilderFactory.newDocumentBuilder().parse(bis);
}
} catch (Exception ex) {
throw new IllegalArgumentException("Error in converting SOAP Envelope to Document", ex);
}
}
/**
* Converts a given {@link Document} to an AXIOM {@link org.apache.axiom.soap.SOAPEnvelope}.
*
* @param document the document to be converted
* @return the converted envelope
* @throws IllegalArgumentException in case of errors
*/
public static SOAPEnvelope toEnvelope(Document document) {
return OMXMLBuilderFactory.createSOAPModelBuilder(new DOMSource(document)).getSOAPEnvelope();
}
}

View File

@@ -1,5 +0,0 @@
<html>
<body>
Support classes for working with the AXis Object Model (AXIOM).
</body>
</html>

View File

@@ -16,18 +16,18 @@
package org.springframework.ws.soap.saaj;
import jakarta.activation.DataHandler;
import jakarta.xml.soap.AttachmentPart;
import jakarta.xml.soap.SOAPException;
import java.io.IOException;
import java.io.InputStream;
import javax.activation.DataHandler;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPException;
import org.springframework.util.Assert;
import org.springframework.ws.mime.Attachment;
/**
* SAAJ-specific implementation of the {@code Attachment} interface. Wraps a {@link javax.xml.soap.AttachmentPart}.
* SAAJ-specific implementation of the {@code Attachment} interface. Wraps a {@link jakarta.xml.soap.AttachmentPart}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,12 +16,13 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPFault;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapVersion;
@@ -29,7 +30,7 @@ import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* SAAJ-specific implementation of the {@code Soap11Body} interface. Wraps a {@link javax.xml.soap.SOAPBody}.
* SAAJ-specific implementation of the {@code Soap11Body} interface. Wraps a {@link jakarta.xml.soap.SOAPBody}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,15 +16,15 @@
package org.springframework.ws.soap.saaj;
import java.util.Locale;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPFault;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import java.util.Locale;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**
* SAAJ-specific implementation of the {@code Soap11Fault} interface. Wraps a {@link javax.xml.soap.SOAPFault}.
* SAAJ-specific implementation of the {@code Soap11Fault} interface. Wraps a {@link jakarta.xml.soap.SOAPFault}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,21 +16,21 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.SOAPConstants;
import jakarta.xml.soap.SOAPHeader;
import jakarta.xml.soap.SOAPHeaderElement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.soap11.Soap11Header;
/**
* SAAJ-specific implementation of the {@code Soap11Header} interface. Wraps a {@link javax.xml.soap.SOAPHeader}.
* SAAJ-specific implementation of the {@code Soap11Header} interface. Wraps a {@link jakarta.xml.soap.SOAPHeader}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,12 +16,13 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPFault;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapVersion;
@@ -29,7 +30,7 @@ import org.springframework.ws.soap.soap12.Soap12Body;
import org.springframework.ws.soap.soap12.Soap12Fault;
/**
* SAAJ-specific implementation of the {@code Soap12Body} interface. Wraps a {@link javax.xml.soap.SOAPBody}.
* SAAJ-specific implementation of the {@code Soap12Body} interface. Wraps a {@link jakarta.xml.soap.SOAPBody}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,12 +16,13 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPFault;
import java.util.Iterator;
import java.util.Locale;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.ws.soap.soap12.Soap12Fault;

View File

@@ -16,15 +16,16 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.SOAPConstants;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPHeader;
import jakarta.xml.soap.SOAPHeaderElement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -33,7 +34,7 @@ import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.ws.soap.soap12.Soap12Header;
/**
* SAAJ-specific implementation of the {@code Soap12Header} interface. Wraps a {@link javax.xml.soap.SOAPHeader}.
* SAAJ-specific implementation of the {@code Soap12Header} interface. Wraps a {@link jakarta.xml.soap.SOAPHeader}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,8 +16,9 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPElement;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
@@ -27,7 +28,7 @@ import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
* SAAJ-specific abstract base class of the {@code SoapBody} interface. Wraps a {@link javax.xml.soap.SOAPBody}.
* SAAJ-specific abstract base class of the {@code SoapBody} interface. Wraps a {@link jakarta.xml.soap.SOAPBody}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,11 +16,12 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.SOAPElement;
import jakarta.xml.soap.SOAPException;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
@@ -28,7 +29,7 @@ import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapElement;
/**
* SAAJ-specific implementation of the {@code SoapElement} interface. Wraps a {@link javax.xml.soap.SOAPElement}.
* SAAJ-specific implementation of the {@code SoapElement} interface. Wraps a {@link jakarta.xml.soap.SOAPElement}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,10 +16,10 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPEnvelope;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPHeader;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapEnvelope;
@@ -27,7 +27,7 @@ import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapVersion;
/**
* SAAJ-specific implementation of the {@code SoapEnvelope} interface. Wraps a {@link javax.xml.soap.SOAPEnvelope}.
* SAAJ-specific implementation of the {@code SoapEnvelope} interface. Wraps a {@link jakarta.xml.soap.SOAPEnvelope}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,16 +16,17 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.Detail;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPFault;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapFaultDetail;
/**
* SAAJ-specific abstract base class of the {@code SoapFault} interface. Wraps a {@link javax.xml.soap.SOAPFault}.
* SAAJ-specific abstract base class of the {@code SoapFault} interface. Wraps a {@link jakarta.xml.soap.SOAPFault}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,13 +16,14 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.Detail;
import jakarta.xml.soap.DetailEntry;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPFaultElement;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.Detail;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFaultElement;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
@@ -32,7 +33,7 @@ import org.springframework.ws.soap.SoapFaultDetailElement;
/**
* SAAJ-specific implementation of the {@code SoapFaultDetail} interface. Wraps a
* {@link javax.xml.soap.SOAPFaultElement}.
* {@link jakarta.xml.soap.SOAPFaultElement}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,8 +16,9 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.DetailEntry;
import javax.xml.soap.SOAPException;
import jakarta.xml.soap.DetailEntry;
import jakarta.xml.soap.SOAPException;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
@@ -25,7 +26,7 @@ import org.springframework.ws.soap.SoapFaultDetailElement;
/**
* SAAJ-specific implementation of the {@code SoapFaultDetailElement} interface. Wraps a
* {@link javax.xml.soap.DetailEntry}.
* {@link jakarta.xml.soap.DetailEntry}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,13 +16,14 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.Node;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPHeader;
import jakarta.xml.soap.SOAPHeaderElement;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.Node;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
@@ -32,7 +33,7 @@ import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
/**
* SAAJ-specific implementation of the {@code SoapHeader} interface. Wraps a {@link javax.xml.soap.SOAPHeader}.
* SAAJ-specific implementation of the {@code SoapHeader} interface. Wraps a {@link jakarta.xml.soap.SOAPHeader}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,7 +16,8 @@
package org.springframework.ws.soap.saaj;
import javax.xml.soap.SOAPHeaderElement;
import jakarta.xml.soap.SOAPHeaderElement;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
@@ -25,7 +26,7 @@ import org.springframework.ws.soap.SoapHeaderException;
/**
* SAAJ-specific implementation of the {@code SoapHeaderElement} interface. Wraps a
* {@link javax.xml.soap.SOAPHeaderElement}.
* {@link jakarta.xml.soap.SOAPHeaderElement}.
*
* @author Arjen Poutsma
* @since 1.0.0

View File

@@ -16,24 +16,15 @@
package org.springframework.ws.soap.saaj;
import jakarta.activation.DataHandler;
import jakarta.xml.soap.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
import javax.activation.DataHandler;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.ws.mime.Attachment;

View File

@@ -16,6 +16,12 @@
package org.springframework.ws.soap.saaj;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.SOAPConstants;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -24,12 +30,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
@@ -49,8 +49,8 @@ import org.xml.sax.SAXParseException;
* SAAJ-specific implementation of the {@link org.springframework.ws.WebServiceMessageFactory WebServiceMessageFactory}.
* Wraps a SAAJ {@link MessageFactory}. This factory will use SAAJ 1.3 when found, or fall back to SAAJ 1.2 or even 1.1.
* <p>
* A SAAJ {@link MessageFactory} can be injected to the {@link #SaajSoapMessageFactory(javax.xml.soap.MessageFactory)
* constructor}, or by the {@link #setMessageFactory(javax.xml.soap.MessageFactory)} property. When a SAAJ message
* A SAAJ {@link MessageFactory} can be injected to the {@link #SaajSoapMessageFactory(jakarta.xml.soap.MessageFactory)
* constructor}, or by the {@link #setMessageFactory(jakarta.xml.soap.MessageFactory)} property. When a SAAJ message
* factory is injected, the {@link #setSoapVersion(org.springframework.ws.soap.SoapVersion)} property is ignored.
*
* @author Arjen Poutsma
@@ -90,8 +90,8 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB
/**
* Sets the SAAJ message properties. These properties will be set on created messages.
*
* @see javax.xml.soap.SOAPMessage#setProperty(String, Object)
*
* @see jakarta.xml.soap.SOAPMessage#setProperty(String, Object)
*/
public void setMessageProperties(Map<String, ?> messageProperties) {
this.messageProperties = messageProperties;
@@ -269,7 +269,7 @@ public class SaajSoapMessageFactory implements SoapMessageFactory, InitializingB
* Template method that allows for post-processing of the given {@link SOAPMessage}.
* <p>
* Default implementation sets {@linkplain SOAPMessage#setProperty(String, Object) message properties}, if any.
*
*
* @param soapMessage the message to post process
* @see #setMessageProperties(java.util.Map)
*/

View File

@@ -16,14 +16,14 @@
package org.springframework.ws.soap.saaj.support;
import jakarta.xml.soap.Name;
import jakarta.xml.soap.SOAPElement;
import jakarta.xml.soap.SOAPEnvelope;
import jakarta.xml.soap.SOAPException;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.xml.sax.Attributes;
@@ -36,8 +36,8 @@ import org.xml.sax.SAXException;
* {@code SOAPElement}s.
*
* @author Arjen Poutsma
* @see javax.xml.soap.Node
* @see javax.xml.soap.SOAPElement
* @see jakarta.xml.soap.Node
* @see jakarta.xml.soap.SOAPElement
* @since 1.0.0
*/
public class SaajContentHandler implements ContentHandler {

View File

@@ -16,19 +16,20 @@
package org.springframework.ws.soap.saaj.support;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.Name;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPElement;
import jakarta.xml.soap.SOAPEnvelope;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
@@ -78,7 +79,7 @@ public abstract class SaajUtils {
}
/**
* Gets the SAAJ version for the specified {@link javax.xml.soap.SOAPElement}. Returns {@link #SAAJ_13} as of
* Gets the SAAJ version for the specified {@link jakarta.xml.soap.SOAPElement}. Returns {@link #SAAJ_13} as of
* Spring-WS 2.2.
*
* @return a code comparable to the SAAJ_XX codes in this class
@@ -147,7 +148,7 @@ public abstract class SaajUtils {
}
/**
* Converts a {@code javax.xml.soap.Name} to a {@code javax.xml.namespace.QName}.
* Converts a {@code jakarta.xml.soap.Name} to a {@code javax.xml.namespace.QName}.
*
* @param name the {@code Name} to convert
* @return the converted {@code QName}

View File

@@ -16,12 +16,12 @@
package org.springframework.ws.soap.saaj.support;
import java.util.Iterator;
import jakarta.xml.soap.Name;
import jakarta.xml.soap.Node;
import jakarta.xml.soap.SOAPElement;
import jakarta.xml.soap.Text;
import javax.xml.soap.Name;
import javax.xml.soap.Node;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.Text;
import java.util.Iterator;
import org.springframework.util.StringUtils;
import org.springframework.xml.sax.AbstractXmlReader;
@@ -37,8 +37,8 @@ import org.xml.sax.helpers.AttributesImpl;
* and calls the corresponding methods on the SAX callback interfaces.
*
* @author Arjen Poutsma
* @see javax.xml.soap.Node
* @see javax.xml.soap.SOAPElement
* @see jakarta.xml.soap.Node
* @see jakarta.xml.soap.SOAPElement
* @since 1.0.0
*/
public class SaajXmlReader extends AbstractXmlReader {

View File

@@ -23,7 +23,6 @@ import org.springframework.ws.server.EndpointInterceptor;
import org.springframework.ws.server.EndpointInvocationChain;
import org.springframework.ws.server.endpoint.mapping.AbstractMapBasedEndpointMapping;
import org.springframework.ws.soap.SoapMessage;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
import org.springframework.ws.soap.server.SoapEndpointMapping;
@@ -36,16 +35,16 @@ import org.springframework.ws.soap.server.SoapEndpointMapping;
* <p>
* Mappings to bean names can be set via the {@code mappings} property, in a form accepted by the
* {@code java.util.Properties} class, like as follows:
*
*
* <pre>
* http://www.springframework.org/spring-ws/samples/airline/BookFlight=bookFlightEndpoint
* http://www.springframework.org/spring-ws/samples/airline/GetFlights=getFlightsEndpoint
* </pre>
*
*
* The syntax is SOAP_ACTION=ENDPOINT_BEAN_NAME.
* <p>
* This endpoint mapping does not read from the request message, and therefore is more suitable for message factories
* which directly read from the transport request (such as the {@link AxiomSoapMessageFactory} with the
* which directly read from the transport request (such as the {@link org.springframework.ws.soap.saaj.SaajSoapMessageFactory} with the
* {@code payloadCaching} disabled).
*
* @author Arjen Poutsma

View File

@@ -16,14 +16,14 @@
package org.springframework.ws.support;
import jakarta.servlet.ServletContext;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import javax.servlet.ServletContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;

View File

@@ -16,9 +16,10 @@
package org.springframework.ws.support;
import jakarta.activation.DataHandler;
import java.io.IOException;
import javax.activation.DataHandler;
import javax.xml.transform.Source;
import org.springframework.oxm.Marshaller;

View File

@@ -16,6 +16,10 @@
package org.springframework.ws.transport.http;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.xml.soap.SOAPConstants;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -23,10 +27,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPConstants;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.transport.AbstractReceiverConnection;

View File

@@ -16,9 +16,9 @@
package org.springframework.ws.transport.http;
import java.util.List;
import jakarta.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -44,7 +44,7 @@ public abstract class LocationTransformerObjectSupport extends TransformerObject
/**
* Transforms the locations of the given definition document using the given XPath expression.
*
*
* @param xPathExpression the XPath expression
* @param definitionDocument the definition document
* @param request the request, used to determine the location to transform to

View File

@@ -18,8 +18,8 @@ package org.springframework.ws.transport.http;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.BeanInitializationException;
@@ -272,7 +272,7 @@ public class MessageDispatcherServlet extends FrameworkServlet {
this.xsdSchemaHandlerAdapterBeanName = xsdSchemaHandlerAdapterBeanName;
}
@Override
@Override
protected void doService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception {
WsdlDefinition definition = getWsdlDefinition(httpServletRequest);

View File

@@ -16,8 +16,8 @@
package org.springframework.ws.transport.http;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.ModelAndView;

View File

@@ -16,11 +16,12 @@
package org.springframework.ws.transport.http;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMResult;
@@ -64,7 +65,7 @@ import org.w3c.dom.Document;
* @see WsdlDefinition
* @see #setTransformLocations(boolean)
* @see #setLocationExpression(String)
* @see #transformLocation(String,javax.servlet.http.HttpServletRequest)
* @see #transformLocation(String,jakarta.servlet.http.HttpServletRequest)
* @since 1.0.0
*/
public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSupport
@@ -184,7 +185,7 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo
*
* @see #setLocationExpression(String)
* @see #setTransformLocations(boolean)
* @see #transformLocation(String,javax.servlet.http.HttpServletRequest)
* @see #transformLocation(String,jakarta.servlet.http.HttpServletRequest)
*/
protected void transformLocations(Document definitionDocument, HttpServletRequest request) throws Exception {
transformLocations(locationXPathExpression, definitionDocument, request);
@@ -199,7 +200,7 @@ public class WsdlDefinitionHandlerAdapter extends LocationTransformerObjectSuppo
*
* @see #setSchemaLocationExpression(String)
* @see #setTransformSchemaLocations(boolean)
* @see #transformLocation(String,javax.servlet.http.HttpServletRequest)
* @see #transformLocation(String,jakarta.servlet.http.HttpServletRequest)
*/
protected void transformSchemaLocations(Document definitionDocument, HttpServletRequest request) throws Exception {
transformLocations(schemaLocationXPathExpression, definitionDocument, request);

View File

@@ -16,11 +16,12 @@
package org.springframework.ws.transport.http;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.dom.DOMResult;
@@ -144,7 +145,7 @@ public class XsdSchemaHandlerAdapter extends LocationTransformerObjectSupport
* This method is only called when the {@code transformSchemaLocations} property is true.
*
* @see #setSchemaLocationExpression(String)
* @see #transformLocation(String, javax.servlet.http.HttpServletRequest)
* @see #transformLocation(String, jakarta.servlet.http.HttpServletRequest)
*/
protected void transformSchemaLocations(Document definitionDocument, HttpServletRequest request) throws Exception {
transformLocations(schemaLocationXPathExpression, definitionDocument, request);

View File

@@ -16,9 +16,9 @@
package org.springframework.ws.transport.http.support;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRegistration;
import org.springframework.util.Assert;
import org.springframework.web.context.AbstractContextLoaderInitializer;
@@ -68,7 +68,7 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra
* it to the patterns returned from {@link #getServletMappings()}.
* <p>
* Further customization can be achieved by overriding {@link #customizeRegistration(ServletRegistration.Dynamic)}.
*
*
* @param servletContext the context to register the servlet against
*/
protected void registerMessageDispatcherServlet(ServletContext servletContext) {
@@ -97,7 +97,7 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra
/**
* Return the name under which the {@link MessageDispatcherServlet} will be registered. Defaults to
* {@link #DEFAULT_SERVLET_NAME}.
*
*
* @see #registerMessageDispatcherServlet(ServletContext)
*/
protected String getServletName() {
@@ -110,7 +110,7 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra
* The returned context is delegated to Spring's
* {@link MessageDispatcherServlet#MessageDispatcherServlet(WebApplicationContext)}. As such, it typically contains
* endpoints, interceptors and other web service-related beans.
*
*
* @see #registerMessageDispatcherServlet(ServletContext)
*/
protected abstract WebApplicationContext createServletApplicationContext();
@@ -118,7 +118,7 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra
/**
* Specify the servlet mapping(s) for the {@code MessageDispatcherServlet}. Defaults to
* {@link #DEFAULT_SERVLET_MAPPINGS}.
*
*
* @see #registerMessageDispatcherServlet(ServletContext)
*/
protected String[] getServletMappings() {
@@ -144,7 +144,7 @@ public abstract class AbstractMessageDispatcherServletInitializer extends Abstra
/**
* Optionally perform further registration customization once
* {@link #registerMessageDispatcherServlet(ServletContext)} has completed.
*
*
* @param registration the {@code MessageDispatcherServlet} registration to be customized
* @see #registerMessageDispatcherServlet(ServletContext)
*/

View File

@@ -18,38 +18,43 @@ package org.springframework.ws.client.core;
import static org.assertj.core.api.Assertions.*;
import jakarta.activation.DataHandler;
import jakarta.mail.util.ByteArrayDataSource;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeader;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.StringTokenizer;
import javax.activation.DataHandler;
import javax.mail.util.ByteArrayDataSource;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.oxm.XmlMappingException;
@@ -75,6 +80,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase {
private String messagePayload = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
private Logger logger = LogManager.getLogger();
@BeforeAll
public static void startJetty() throws Exception {
@@ -82,20 +89,28 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase {
baseUrl = "http://localhost:" + port;
jettyServer = new Server(port);
Connector connector = new ServerConnector(jettyServer);
jettyServer.addConnector(connector);
Context jettyContext = new Context(jettyServer, "/");
jettyContext.addServlet(new ServletHolder(new EchoSoapServlet()), "/soap/echo");
jettyContext.addServlet(new ServletHolder(new SoapFaultServlet()), "/soap/fault");
ServletContextHandler jettyContext = new ServletContextHandler();
jettyContext.setContextPath("/");
SoapFaultServlet badRequestFault = new SoapFaultServlet();
badRequestFault.setSc(400);
jettyContext.addServlet(EchoSoapServlet.class, "/soap/echo");
jettyContext.addServlet(SoapFaultServlet.class, "/soap/fault");
jettyContext.addServlet(new ServletHolder(badRequestFault), "/soap/badRequestFault");
jettyContext.addServlet(new ServletHolder(new NoResponseSoapServlet()), "/soap/noResponse");
jettyContext.addServlet(new ServletHolder(new AttachmentsServlet()), "/soap/attachment");
jettyContext.addServlet(new ServletHolder(new ErrorServlet(404)), "/errors/notfound");
jettyContext.addServlet(new ServletHolder(new ErrorServlet(500)), "/errors/server");
ServletHolder badRequestFault = jettyContext.addServlet(SoapFaultServlet.class, "/soap/badRequestFault");
badRequestFault.setInitParameter("sc", "400");
jettyContext.addServlet(NoResponseSoapServlet.class, "/soap/noResponse");
jettyContext.addServlet(AttachmentsServlet.class, "/soap/attachment");
ServletHolder notfound = jettyContext.addServlet(ErrorServlet.class, "/errors/notfound");
notfound.setInitParameter("sc", "404");
ServletHolder errors = jettyContext.addServlet(ErrorServlet.class, "/errors/server");
errors.setInitParameter("sc", "500");
jettyServer.setHandler(jettyContext);
jettyServer.start();
}
@@ -119,6 +134,8 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase {
@Test
public void sendSourceAndReceiveToResult() {
logger.info(">>> Test case");
StringResult result = new StringResult();
boolean b = template.sendSourceAndReceiveToResult(baseUrl + "/soap/echo", new StringSource(messagePayload), result);
@@ -364,7 +381,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class EchoSoapServlet extends AbstractSoapServlet {
public static class EchoSoapServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) {
@@ -373,7 +390,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class NoResponseSoapServlet extends AbstractSoapServlet {
public static class NoResponseSoapServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) {
@@ -382,7 +399,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class SoapFaultServlet extends AbstractSoapServlet {
public static class SoapFaultServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) throws SOAPException {
@@ -395,7 +412,7 @@ public abstract class AbstractSoap11WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class AttachmentsServlet extends AbstractSoapServlet {
public static class AttachmentsServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) {

View File

@@ -18,40 +18,43 @@ package org.springframework.ws.client.core;
import static org.assertj.core.api.Assertions.*;
import jakarta.activation.CommandMap;
import jakarta.activation.DataHandler;
import jakarta.activation.MailcapCommandMap;
import jakarta.mail.util.ByteArrayDataSource;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeader;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPConstants;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.StringTokenizer;
import javax.activation.CommandMap;
import javax.activation.DataHandler;
import javax.activation.MailcapCommandMap;
import javax.mail.util.ByteArrayDataSource;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.oxm.XmlMappingException;
@@ -81,15 +84,27 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
int port = FreePortScanner.getFreePort();
baseUrl = "http://localhost:" + port;
jettyServer = new Server(port);
Context jettyContext = new Context(jettyServer, "/");
jettyContext.addServlet(new ServletHolder(new EchoSoapServlet()), "/soap/echo");
jettyContext.addServlet(new ServletHolder(new SoapReceiverFaultServlet()), "/soap/receiverFault");
jettyContext.addServlet(new ServletHolder(new SoapSenderFaultServlet()), "/soap/senderFault");
jettyContext.addServlet(new ServletHolder(new NoResponseSoapServlet()), "/soap/noResponse");
jettyContext.addServlet(new ServletHolder(new AttachmentsServlet()), "/soap/attachment");
jettyContext.addServlet(new ServletHolder(new ErrorServlet(404)), "/errors/notfound");
jettyContext.addServlet(new ServletHolder(new ErrorServlet(500)), "/errors/server");
Connector connector = new ServerConnector(jettyServer);
jettyServer.addConnector(connector);
ServletContextHandler jettyContext = new ServletContextHandler();
jettyContext.setContextPath("/");
jettyContext.addServlet(EchoSoapServlet.class, "/soap/echo");
jettyContext.addServlet(SoapReceiverFaultServlet.class, "/soap/receiverFault");
jettyContext.addServlet(SoapSenderFaultServlet.class, "/soap/senderFault");
jettyContext.addServlet(NoResponseSoapServlet.class, "/soap/noResponse");
jettyContext.addServlet(AttachmentsServlet.class, "/soap/attachment");
ServletHolder notfound = jettyContext.addServlet(ErrorServlet.class, "/errors/notfound");
notfound.setInitParameter("sc", "404");
ServletHolder errors = jettyContext.addServlet(ErrorServlet.class, "/errors/server");
errors.setInitParameter("sc", "500");
jettyServer.setHandler(jettyContext);
jettyServer.start();
}
@@ -265,7 +280,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
/** Servlet that returns and error message for a given status code. */
@SuppressWarnings("serial")
private static class ErrorServlet extends HttpServlet {
public static class ErrorServlet extends HttpServlet {
private int sc;
@@ -281,7 +296,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
/** Abstract SOAP Servlet */
@SuppressWarnings("serial")
private abstract static class AbstractSoapServlet extends HttpServlet {
public abstract static class AbstractSoapServlet extends HttpServlet {
protected MessageFactory messageFactory = null;
@@ -362,7 +377,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class EchoSoapServlet extends AbstractSoapServlet {
public static class EchoSoapServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) {
@@ -371,7 +386,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class NoResponseSoapServlet extends AbstractSoapServlet {
public static class NoResponseSoapServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) {
@@ -380,7 +395,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class SoapReceiverFaultServlet extends AbstractSoapServlet {
public static class SoapReceiverFaultServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) throws SOAPException {
@@ -393,7 +408,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class SoapSenderFaultServlet extends AbstractSoapServlet {
public static class SoapSenderFaultServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) throws SOAPException {
@@ -406,7 +421,7 @@ public abstract class AbstractSoap12WebServiceTemplateIntegrationTestCase {
}
@SuppressWarnings("serial")
private static class AttachmentsServlet extends AbstractSoapServlet {
public static class AttachmentsServlet extends AbstractSoapServlet {
@Override
protected SOAPMessage onMessage(SOAPMessage message) {

View File

@@ -1,32 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.client.core;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
/**
* @author Arjen Poutsma
*/
public class AxiomNonStreamingSoap11WebServiceTemplateIntegrationTest
extends AbstractSoap11WebServiceTemplateIntegrationTestCase {
@Override
public SoapMessageFactory createMessageFactory() throws Exception {
return new AxiomSoapMessageFactory();
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.client.core;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
/**
* @author Arjen Poutsma
*/
public class AxiomNonStreamingSoap12WebServiceTemplateIntegrationTest
extends AbstractSoap12WebServiceTemplateIntegrationTestCase {
@Override
public SoapMessageFactory createMessageFactory() {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
messageFactory.setSoapVersion(SoapVersion.SOAP_12);
return messageFactory;
}
}

View File

@@ -1,34 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.client.core;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
/**
* @author Arjen Poutsma
*/
public class AxiomStreamingSoap11WebServiceTemplateIntegrationTest
extends AbstractSoap11WebServiceTemplateIntegrationTestCase {
@Override
public SoapMessageFactory createMessageFactory() throws Exception {
AxiomSoapMessageFactory axiomFactory = new AxiomSoapMessageFactory();
axiomFactory.setPayloadCaching(false);
return axiomFactory;
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed 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.springframework.ws.client.core;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
/**
* @author Arjen Poutsma
*/
public class AxiomStreamingSoap12WebServiceTemplateIntegrationTest
extends AbstractSoap12WebServiceTemplateIntegrationTestCase {
@Override
public SoapMessageFactory createMessageFactory() throws Exception {
AxiomSoapMessageFactory axiomFactory = new AxiomSoapMessageFactory();
axiomFactory.setSoapVersion(SoapVersion.SOAP_12);
axiomFactory.setPayloadCaching(false);
return axiomFactory;
}
}

View File

@@ -18,13 +18,14 @@ package org.springframework.ws.client.core;
import static org.assertj.core.api.Assertions.*;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
@@ -32,12 +33,14 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.springframework.ws.client.WebServiceTransportException;
import org.springframework.ws.pox.dom.DomPoxMessageFactory;
import org.springframework.ws.transport.http.HttpComponentsMessageSender;
@@ -60,11 +63,23 @@ public class DomPoxWebServiceTemplateIntegrationTest {
int port = FreePortScanner.getFreePort();
baseUrl = "http://localhost:" + port;
jettyServer = new Server(port);
Context jettyContext = new Context(jettyServer, "/");
jettyContext.addServlet(new ServletHolder(new PoxServlet()), "/pox");
jettyContext.addServlet(new ServletHolder(new ErrorServlet(404)), "/errors/notfound");
jettyContext.addServlet(new ServletHolder(new ErrorServlet(500)), "/errors/server");
Connector connector = new ServerConnector(jettyServer);
jettyServer.addConnector(connector);
ServletContextHandler jettyContext = new ServletContextHandler();
jettyContext.setContextPath("/");
jettyContext.addServlet(PoxServlet.class, "/pox");
ServletHolder notfound = jettyContext.addServlet(ErrorServlet.class, "/errors/notfound");
notfound.setInitParameter("sc", "404");
ServletHolder errors = jettyContext.addServlet(ErrorServlet.class, "/errors/server");
errors.setInitParameter("sc", "500");
jettyServer.setHandler(jettyContext);
jettyServer.start();
}
@@ -94,7 +109,7 @@ public class DomPoxWebServiceTemplateIntegrationTest {
/** Servlet that returns and error message for a given status code. */
@SuppressWarnings("serial")
private static class ErrorServlet extends HttpServlet {
public static class ErrorServlet extends HttpServlet {
private int sc;
@@ -110,7 +125,7 @@ public class DomPoxWebServiceTemplateIntegrationTest {
/** Simple POX Servlet. */
@SuppressWarnings("serial")
private static class PoxServlet extends HttpServlet {
public static class PoxServlet extends HttpServlet {
private DocumentBuilderFactory documentBuilderFactory;

View File

@@ -16,8 +16,8 @@
package org.springframework.ws.client.core;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.SOAPConstants;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;

View File

@@ -16,8 +16,8 @@
package org.springframework.ws.client.core;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.SOAPConstants;
import org.springframework.ws.soap.SoapMessageFactory;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;

View File

@@ -16,21 +16,21 @@
package org.springframework.ws.client.core;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeader;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.StringTokenizer;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeader;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.springframework.util.StringUtils;
/**

View File

@@ -17,7 +17,7 @@
package org.springframework.ws.client.core;
import static org.assertj.core.api.Assertions.*;
import static org.easymock.EasyMock.*;
import static org.mockito.Mockito.*;
import java.io.IOException;
import java.net.URI;
@@ -57,9 +57,9 @@ public class WebServiceTemplateTest {
messageFactory = new MockWebServiceMessageFactory();
template = new WebServiceTemplate(messageFactory);
connectionMock = createMock(FaultAwareWebServiceConnection.class);
connectionMock = mock(FaultAwareWebServiceConnection.class);
final URI expectedUri = new URI("http://www.springframework.org/spring-ws");
expect(connectionMock.getUri()).andReturn(expectedUri).anyTimes();
when(connectionMock.getUri()).thenReturn(expectedUri);
template.setMessageSender(new WebServiceMessageSender() {
@Override
@@ -83,17 +83,9 @@ public class WebServiceTemplateTest {
connectionMock.close();
replay(connectionMock);
template.setMarshaller(null);
try {
template.marshalSendAndReceive(new Object());
fail("IllegalStateException expected");
} catch (IllegalStateException ex) {
// expected behavior
}
verify(connectionMock);
assertThatIllegalStateException().isThrownBy(() -> template.marshalSendAndReceive(new Object()));
}
@Test
@@ -101,69 +93,52 @@ public class WebServiceTemplateTest {
connectionMock.close();
replay(connectionMock);
template.setUnmarshaller(null);
try {
template.marshalSendAndReceive(new Object());
fail("IllegalStateException expected");
} catch (IllegalStateException ex) {
// expected behavior
}
verify(connectionMock);
assertThatIllegalStateException().isThrownBy(() -> template.marshalSendAndReceive(new Object()));
}
@Test
public void testSendAndReceiveMessageResponse() throws Exception {
WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class);
WebServiceMessageCallback requestCallback = mock(WebServiceMessageCallback.class);
requestCallback.doWithMessage(isA(WebServiceMessage.class));
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
Object extracted = new Object();
expect(extractorMock.extractData(isA(WebServiceMessage.class))).andReturn(extracted);
when(extractorMock.extractData(isA(WebServiceMessage.class))).thenReturn(extracted);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(new MockWebServiceMessage("<response/>"));
expect(connectionMock.hasFault()).andReturn(false);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(new MockWebServiceMessage("<response/>"));
when(connectionMock.hasFault()).thenReturn(false);
connectionMock.close();
replay(connectionMock, requestCallback, extractorMock);
Object result = template.sendAndReceive(requestCallback, extractorMock);
assertThat(result).isEqualTo(extracted);
verify(connectionMock, requestCallback, extractorMock);
}
@Test
public void testSendAndReceiveMessageNoResponse() throws Exception {
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(null);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(null);
connectionMock.close();
replay(connectionMock, extractorMock);
Object result = template.sendAndReceive(null, extractorMock);
assertThat(result).isNull();
verify(connectionMock, extractorMock);
}
@Test
public void testSendAndReceiveMessageFault() throws Exception {
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
FaultMessageResolver faultMessageResolverMock = createMock(FaultMessageResolver.class);
FaultMessageResolver faultMessageResolverMock = mock(FaultMessageResolver.class);
template.setFaultMessageResolver(faultMessageResolverMock);
faultMessageResolverMock.resolveFault(isA(WebServiceMessage.class));
@@ -171,187 +146,151 @@ public class WebServiceTemplateTest {
response.setFault(true);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.hasFault()).andReturn(true);
expect(connectionMock.receive(messageFactory)).andReturn(response);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.hasFault()).thenReturn(true);
when(connectionMock.receive(messageFactory)).thenReturn(response);
connectionMock.close();
replay(connectionMock, extractorMock, faultMessageResolverMock);
Object result = template.sendAndReceive(null, extractorMock);
assertThat(result).isNull();
verify(connectionMock, extractorMock, faultMessageResolverMock);
}
@Test
public void testSendAndReceiveConnectionError() throws Exception {
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
template.setFaultMessageResolver(null);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(true);
expect(connectionMock.hasFault()).andReturn(false);
when(connectionMock.hasError()).thenReturn(true);
when(connectionMock.hasFault()).thenReturn(false);
String errorMessage = "errorMessage";
expect(connectionMock.getErrorMessage()).andReturn(errorMessage);
when(connectionMock.getErrorMessage()).thenReturn(errorMessage);
connectionMock.close();
replay(connectionMock, extractorMock);
assertThatExceptionOfType(WebServiceTransportException.class)
.isThrownBy(() -> template.sendAndReceive(null, extractorMock)).withMessage(errorMessage);
verify(connectionMock, extractorMock);
}
@Test
public void testSendAndReceiveSourceResponse() throws Exception {
SourceExtractor extractorMock = createMock(SourceExtractor.class);
SourceExtractor extractorMock = mock(SourceExtractor.class);
Object extracted = new Object();
expect(extractorMock.extractData(isA(Source.class))).andReturn(extracted);
when(extractorMock.extractData(isA(Source.class))).thenReturn(extracted);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(new MockWebServiceMessage("<response/>"));
expect(connectionMock.hasFault()).andReturn(false);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(new MockWebServiceMessage("<response/>"));
when(connectionMock.hasFault()).thenReturn(false);
connectionMock.close();
replay(connectionMock, extractorMock);
Object result = template.sendSourceAndReceive(new StringSource("<request />"), extractorMock);
assertThat(result).isEqualTo(extracted);
verify(connectionMock, extractorMock);
}
@Test
public void testSendAndReceiveSourceNoResponse() throws Exception {
SourceExtractor extractorMock = createMock(SourceExtractor.class);
SourceExtractor extractorMock = mock(SourceExtractor.class);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(null);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(null);
connectionMock.close();
replay(connectionMock, extractorMock);
Object result = template.sendSourceAndReceive(new StringSource("<request />"), extractorMock);
assertThat(result).isNull();
verify(connectionMock, extractorMock);
}
@Test
public void testSendAndReceiveResultResponse() throws Exception {
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(new MockWebServiceMessage("<response/>"));
expect(connectionMock.hasFault()).andReturn(false);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(new MockWebServiceMessage("<response/>"));
when(connectionMock.hasFault()).thenReturn(false);
connectionMock.close();
replay(connectionMock);
StringResult result = new StringResult();
boolean b = template.sendSourceAndReceiveToResult(new StringSource("<request />"), result);
assertThat(b).isTrue();
verify(connectionMock);
}
@Test
public void testSendAndReceiveResultNoResponse() throws Exception {
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(null);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(null);
connectionMock.close();
replay(connectionMock);
StringResult result = new StringResult();
boolean b = template.sendSourceAndReceiveToResult(new StringSource("<request />"), result);
assertThat(b).isFalse();
verify(connectionMock);
}
@Test
public void testSendAndReceiveResultNoResponsePayload() throws Exception {
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
WebServiceMessage response = createMock(WebServiceMessage.class);
expect(connectionMock.receive(messageFactory)).andReturn(response);
expect(connectionMock.hasFault()).andReturn(false);
expect(response.getPayloadSource()).andReturn(null);
when(connectionMock.hasError()).thenReturn(false);
WebServiceMessage response = mock(WebServiceMessage.class);
when(connectionMock.receive(messageFactory)).thenReturn(response);
when(connectionMock.hasFault()).thenReturn(false);
when(response.getPayloadSource()).thenReturn(null);
connectionMock.close();
replay(connectionMock, response);
StringResult result = new StringResult();
boolean b = template.sendSourceAndReceiveToResult(new StringSource("<request />"), result);
assertThat(b).isTrue();
verify(connectionMock, response);
}
@Test
public void testSendAndReceiveMarshalResponse() throws Exception {
Marshaller marshallerMock = createMock(Marshaller.class);
Marshaller marshallerMock = mock(Marshaller.class);
template.setMarshaller(marshallerMock);
marshallerMock.marshal(isA(Object.class), isA(Result.class));
Unmarshaller unmarshallerMock = createMock(Unmarshaller.class);
Unmarshaller unmarshallerMock = mock(Unmarshaller.class);
template.setUnmarshaller(unmarshallerMock);
Object unmarshalled = new Object();
expect(unmarshallerMock.unmarshal(isA(Source.class))).andReturn(unmarshalled);
when(unmarshallerMock.unmarshal(isA(Source.class))).thenReturn(unmarshalled);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(new MockWebServiceMessage("<response/>"));
expect(connectionMock.hasFault()).andReturn(false);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(new MockWebServiceMessage("<response/>"));
when(connectionMock.hasFault()).thenReturn(false);
connectionMock.close();
replay(connectionMock, marshallerMock, unmarshallerMock);
Object result = template.marshalSendAndReceive(new Object());
assertThat(result).isEqualTo(unmarshalled);
verify(connectionMock, marshallerMock, unmarshallerMock);
}
@Test
public void testSendAndReceiveMarshalNoResponse() throws Exception {
Marshaller marshallerMock = createMock(Marshaller.class);
Marshaller marshallerMock = mock(Marshaller.class);
template.setMarshaller(marshallerMock);
marshallerMock.marshal(isA(Object.class), isA(Result.class));
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(null);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(null);
connectionMock.close();
replay(connectionMock, marshallerMock);
Object result = template.marshalSendAndReceive(new Object());
assertThat(result).isNull();
verify(connectionMock, marshallerMock);
}
@Test
@@ -372,61 +311,53 @@ public class WebServiceTemplateTest {
return true;
}
});
WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class);
WebServiceMessageCallback requestCallback = mock(WebServiceMessageCallback.class);
requestCallback.doWithMessage(isA(WebServiceMessage.class));
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
Object extracted = new Object();
expect(extractorMock.extractData(isA(WebServiceMessage.class))).andReturn(extracted);
when(extractorMock.extractData(isA(WebServiceMessage.class))).thenReturn(extracted);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(new MockWebServiceMessage("<response/>"));
expect(connectionMock.hasFault()).andReturn(false);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(new MockWebServiceMessage("<response/>"));
when(connectionMock.hasFault()).thenReturn(false);
connectionMock.close();
replay(connectionMock, requestCallback, extractorMock);
Object result = template.sendAndReceive(customUri.toString(), requestCallback, extractorMock);
assertThat(result).isEqualTo(extracted);
verify(connectionMock, requestCallback, extractorMock);
}
@Test
public void testInterceptors() throws Exception {
ClientInterceptor interceptorMock1 = createStrictMock("interceptor1", ClientInterceptor.class);
ClientInterceptor interceptorMock2 = createStrictMock("interceptor2", ClientInterceptor.class);
ClientInterceptor interceptorMock1 = mock(ClientInterceptor.class);
ClientInterceptor interceptorMock2 = mock(ClientInterceptor.class);
template.setInterceptors(new ClientInterceptor[] { interceptorMock1, interceptorMock2 });
expect(interceptorMock1.handleRequest(isA(MessageContext.class))).andReturn(true);
expect(interceptorMock2.handleRequest(isA(MessageContext.class))).andReturn(true);
expect(interceptorMock2.handleResponse(isA(MessageContext.class))).andReturn(true);
expect(interceptorMock1.handleResponse(isA(MessageContext.class))).andReturn(true);
when(interceptorMock1.handleRequest(isA(MessageContext.class))).thenReturn(true);
when(interceptorMock2.handleRequest(isA(MessageContext.class))).thenReturn(true);
when(interceptorMock2.handleResponse(isA(MessageContext.class))).thenReturn(true);
when(interceptorMock1.handleResponse(isA(MessageContext.class))).thenReturn(true);
interceptorMock2.afterCompletion(isA(MessageContext.class), (Exception) isNull());
interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception) isNull());
WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class);
WebServiceMessageCallback requestCallback = mock(WebServiceMessageCallback.class);
requestCallback.doWithMessage(isA(WebServiceMessage.class));
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
Object extracted = new Object();
expect(extractorMock.extractData(isA(WebServiceMessage.class))).andReturn(extracted);
when(extractorMock.extractData(isA(WebServiceMessage.class))).thenReturn(extracted);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(new MockWebServiceMessage("<response/>"));
expect(connectionMock.hasFault()).andReturn(false);
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(new MockWebServiceMessage("<response/>"));
when(connectionMock.hasFault()).thenReturn(false);
connectionMock.close();
replay(connectionMock, interceptorMock1, interceptorMock2, requestCallback, extractorMock);
Object result = template.sendAndReceive(requestCallback, extractorMock);
assertThat(result).isEqualTo(extracted);
verify(connectionMock, interceptorMock1, interceptorMock2, requestCallback, extractorMock);
}
@Test
@@ -434,24 +365,20 @@ public class WebServiceTemplateTest {
MessageContext messageContext = new DefaultMessageContext(messageFactory);
ClientInterceptor interceptorMock1 = createStrictMock("interceptor1", ClientInterceptor.class);
ClientInterceptor interceptorMock2 = createStrictMock("interceptor2", ClientInterceptor.class);
ClientInterceptor interceptorMock1 = mock(ClientInterceptor.class);
ClientInterceptor interceptorMock2 = mock(ClientInterceptor.class);
template.setInterceptors(new ClientInterceptor[] { interceptorMock1, interceptorMock2 });
expect(interceptorMock1.handleRequest(isA(MessageContext.class))).andReturn(false);
when(interceptorMock1.handleRequest(isA(MessageContext.class))).thenReturn(false);
interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception) isNull());
WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class);
WebServiceMessageCallback requestCallback = mock(WebServiceMessageCallback.class);
requestCallback.doWithMessage(messageContext.getRequest());
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
replay(connectionMock, interceptorMock1, interceptorMock2, requestCallback, extractorMock);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
Object result = template.doSendAndReceive(messageContext, connectionMock, requestCallback, extractorMock);
assertThat(result).isNull();
verify(connectionMock, interceptorMock1, interceptorMock2, requestCallback, extractorMock);
}
@Test
@@ -461,43 +388,39 @@ public class WebServiceTemplateTest {
// force creation of response
messageContext.getResponse();
ClientInterceptor interceptorMock1 = createStrictMock("interceptor1", ClientInterceptor.class);
ClientInterceptor interceptorMock2 = createStrictMock("interceptor2", ClientInterceptor.class);
ClientInterceptor interceptorMock1 = mock(ClientInterceptor.class);
ClientInterceptor interceptorMock2 = mock(ClientInterceptor.class);
template.setInterceptors(new ClientInterceptor[] { interceptorMock1, interceptorMock2 });
expect(interceptorMock1.handleRequest(isA(MessageContext.class))).andReturn(false);
expect(interceptorMock1.handleResponse(isA(MessageContext.class))).andReturn(true);
when(interceptorMock1.handleRequest(isA(MessageContext.class))).thenReturn(false);
when(interceptorMock1.handleResponse(isA(MessageContext.class))).thenReturn(true);
interceptorMock1.afterCompletion(isA(MessageContext.class), (Exception) isNull());
WebServiceMessageCallback requestCallback = createMock(WebServiceMessageCallback.class);
WebServiceMessageCallback requestCallback = mock(WebServiceMessageCallback.class);
requestCallback.doWithMessage(messageContext.getRequest());
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
Object extracted = new Object();
expect(extractorMock.extractData(messageContext.getResponse())).andReturn(extracted);
when(extractorMock.extractData(messageContext.getResponse())).thenReturn(extracted);
expect(connectionMock.hasFault()).andReturn(false);
replay(connectionMock, interceptorMock1, interceptorMock2, requestCallback, extractorMock);
when(connectionMock.hasFault()).thenReturn(false);
Object result = template.doSendAndReceive(messageContext, connectionMock, requestCallback, extractorMock);
assertThat(result).isEqualTo(extracted);
verify(connectionMock, interceptorMock1, interceptorMock2, requestCallback, extractorMock);
}
@Test
public void testDestinationResolver() throws Exception {
DestinationProvider providerMock = createMock(DestinationProvider.class);
DestinationProvider providerMock = mock(DestinationProvider.class);
template.setDestinationProvider(providerMock);
final URI providerUri = new URI("http://www.springframework.org/spring-ws/destinationProvider");
expect(providerMock.getDestination()).andReturn(providerUri);
when(providerMock.getDestination()).thenReturn(providerUri);
template.setMessageSender(new WebServiceMessageSender() {
@Override
public WebServiceConnection createConnection(URI uri) throws IOException {
public WebServiceConnection createConnection(URI uri) {
return connectionMock;
}
@@ -509,22 +432,18 @@ public class WebServiceTemplateTest {
}
});
WebServiceMessageExtractor extractorMock = createMock(WebServiceMessageExtractor.class);
WebServiceMessageExtractor extractorMock = mock(WebServiceMessageExtractor.class);
reset(connectionMock);
connectionMock.send(isA(WebServiceMessage.class));
expect(connectionMock.hasError()).andReturn(false);
expect(connectionMock.receive(messageFactory)).andReturn(null);
// expect(connectionMock.getUri()).andReturn(new URI("http://example.com"));
when(connectionMock.hasError()).thenReturn(false);
when(connectionMock.receive(messageFactory)).thenReturn(null);
when(connectionMock.getUri()).thenReturn(new URI("http://example.com"));
connectionMock.close();
replay(connectionMock, extractorMock, providerMock);
Object result = template.sendAndReceive(null, extractorMock);
assertThat(result).isNull();
verify(connectionMock, extractorMock, providerMock);
}
}

View File

@@ -18,12 +18,13 @@ package org.springframework.ws.client.support.interceptor;
import static org.assertj.core.api.Assertions.*;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.SOAPConstants;
import jakarta.xml.soap.SOAPMessage;
import java.io.InputStream;
import javax.xml.XMLConstants;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;

View File

@@ -18,20 +18,17 @@ package org.springframework.ws.server.endpoint;
import static org.assertj.core.api.Assertions.*;
import javax.xml.soap.MessageFactory;
import jakarta.xml.soap.MessageFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Transformer;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.soap.SOAPFactory;
import org.junit.jupiter.api.Test;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.axiom.AxiomSoapMessage;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
import org.springframework.xml.transform.StringResult;
@@ -131,10 +128,10 @@ public class StaxStreamPayloadEndpointTest extends AbstractMessageEndpointTestCa
public void testAxiomResponse() throws Exception {
Transformer transformer = TransformerFactoryUtils.newInstance().newTransformer();
SOAPFactory axiomFactory = OMAbstractFactory.getSOAP11Factory();
AxiomSoapMessage request = new AxiomSoapMessage(axiomFactory);
MessageFactory messageFactory = MessageFactory.newInstance();
SaajSoapMessage request = new SaajSoapMessage(messageFactory.createMessage(), true, messageFactory);
transformer.transform(new StringSource(REQUEST), request.getPayloadResult());
AxiomSoapMessageFactory soapMessageFactory = new AxiomSoapMessageFactory();
SaajSoapMessageFactory soapMessageFactory = new SaajSoapMessageFactory();
soapMessageFactory.afterPropertiesSet();
MessageContext context = new DefaultMessageContext(request, soapMessageFactory);
@@ -153,51 +150,10 @@ public class StaxStreamPayloadEndpointTest extends AbstractMessageEndpointTestCa
public void testAxiomNoResponse() throws Exception {
Transformer transformer = TransformerFactoryUtils.newInstance().newTransformer();
SOAPFactory axiomFactory = OMAbstractFactory.getSOAP11Factory();
AxiomSoapMessage request = new AxiomSoapMessage(axiomFactory);
MessageFactory messageFactory = MessageFactory.newInstance();
SaajSoapMessage request = new SaajSoapMessage(messageFactory.createMessage(), true, messageFactory);
transformer.transform(new StringSource(REQUEST), request.getPayloadResult());
AxiomSoapMessageFactory soapMessageFactory = new AxiomSoapMessageFactory();
soapMessageFactory.afterPropertiesSet();
MessageContext context = new DefaultMessageContext(request, soapMessageFactory);
MessageEndpoint endpoint = createNoResponseEndpoint();
endpoint.invoke(context);
assertThat(context.hasResponse()).isFalse();
}
@Test
public void testAxiomResponseNoPayloadCaching() throws Exception {
Transformer transformer = TransformerFactoryUtils.newInstance().newTransformer();
SOAPFactory axiomFactory = OMAbstractFactory.getSOAP11Factory();
AxiomSoapMessage request = new AxiomSoapMessage(axiomFactory);
transformer.transform(new StringSource(REQUEST), request.getPayloadResult());
AxiomSoapMessageFactory soapMessageFactory = new AxiomSoapMessageFactory();
soapMessageFactory.setPayloadCaching(false);
soapMessageFactory.afterPropertiesSet();
MessageContext context = new DefaultMessageContext(request, soapMessageFactory);
MessageEndpoint endpoint = createResponseEndpoint();
endpoint.invoke(context);
assertThat(context.hasResponse()).isTrue();
StringResult stringResult = new StringResult();
transformer.transform(context.getResponse().getPayloadSource(), stringResult);
XmlAssert.assertThat(stringResult.toString()).and(RESPONSE).ignoreWhitespace().areIdentical();
}
@Test
public void testAxiomNoResponseNoPayloadCaching() throws Exception {
Transformer transformer = TransformerFactoryUtils.newInstance().newTransformer();
SOAPFactory axiomFactory = OMAbstractFactory.getSOAP11Factory();
AxiomSoapMessage request = new AxiomSoapMessage(axiomFactory);
transformer.transform(new StringSource(REQUEST), request.getPayloadResult());
AxiomSoapMessageFactory soapMessageFactory = new AxiomSoapMessageFactory();
soapMessageFactory.setPayloadCaching(false);
SaajSoapMessageFactory soapMessageFactory = new SaajSoapMessageFactory();
soapMessageFactory.afterPropertiesSet();
MessageContext context = new DefaultMessageContext(request, soapMessageFactory);

View File

@@ -16,16 +16,16 @@
package org.springframework.ws.server.endpoint.adapter.method;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import javax.xml.transform.TransformerException;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.soap.SOAPFactory;
import org.springframework.ws.MockWebServiceMessage;
import org.springframework.ws.MockWebServiceMessageFactory;
import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.soap.axiom.AxiomSoapMessage;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
import org.springframework.xml.transform.StringSource;
@@ -39,10 +39,10 @@ public class AbstractMethodArgumentResolverTestCase extends TransformerObjectSup
protected static final String XML = "<" + LOCAL_NAME + " xmlns=\"" + NAMESPACE_URI + "\"/>";
protected MessageContext createSaajMessageContext() throws javax.xml.soap.SOAPException {
protected MessageContext createSaajMessageContext() throws SOAPException {
javax.xml.soap.MessageFactory saajFactory = javax.xml.soap.MessageFactory.newInstance();
javax.xml.soap.SOAPMessage saajMessage = saajFactory.createMessage();
MessageFactory saajFactory = MessageFactory.newInstance();
SOAPMessage saajMessage = saajFactory.createMessage();
saajMessage.getSOAPBody().addChildElement(LOCAL_NAME, "", NAMESPACE_URI);
return new DefaultMessageContext(new SaajSoapMessage(saajMessage), new SaajSoapMessageFactory(saajFactory));
@@ -56,10 +56,10 @@ public class AbstractMethodArgumentResolverTestCase extends TransformerObjectSup
protected MessageContext createCachingAxiomMessageContext() throws Exception {
SOAPFactory axiomFactory = OMAbstractFactory.getSOAP11Factory();
AxiomSoapMessage request = new AxiomSoapMessage(axiomFactory, true, false);
MessageFactory messageFactory = MessageFactory.newInstance();
SaajSoapMessage request = new SaajSoapMessage(messageFactory.createMessage(), true, messageFactory);
transform(new StringSource(XML), request.getPayloadResult());
AxiomSoapMessageFactory soapMessageFactory = new AxiomSoapMessageFactory();
SaajSoapMessageFactory soapMessageFactory = new SaajSoapMessageFactory();
soapMessageFactory.afterPropertiesSet();
return new DefaultMessageContext(request, soapMessageFactory);
@@ -67,11 +67,10 @@ public class AbstractMethodArgumentResolverTestCase extends TransformerObjectSup
protected MessageContext createNonCachingAxiomMessageContext() throws Exception {
SOAPFactory axiomFactory = OMAbstractFactory.getSOAP11Factory();
AxiomSoapMessage request = new AxiomSoapMessage(axiomFactory, false, false);
MessageFactory messageFactory = MessageFactory.newInstance();
SaajSoapMessage request = new SaajSoapMessage(messageFactory.createMessage(), true, messageFactory);
transform(new StringSource(XML), request.getPayloadResult());
AxiomSoapMessageFactory soapMessageFactory = new AxiomSoapMessageFactory();
soapMessageFactory.setPayloadCaching(false);
SaajSoapMessageFactory soapMessageFactory = new SaajSoapMessageFactory();
soapMessageFactory.afterPropertiesSet();
return new DefaultMessageContext(request, soapMessageFactory);

View File

@@ -18,14 +18,12 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb;
import static org.assertj.core.api.Assertions.*;
import java.io.ByteArrayOutputStream;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import javax.xml.transform.Transformer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -37,10 +35,6 @@ import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
import org.springframework.ws.soap.axiom.AxiomSoapMessage;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.TransformerFactoryUtils;
import org.xmlunit.assertj.XmlAssert;
public class JaxbElementPayloadMethodProcessorTest {
@@ -134,42 +128,6 @@ public class JaxbElementPayloadMethodProcessorTest {
assertThat(messageContext.hasResponse()).isFalse();
}
@Test
public void handleReturnValueAxiom() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
MessageContext messageContext = new DefaultMessageContext(messageFactory);
MyType type = new MyType();
type.setString("Foo");
JAXBElement<MyType> element = new JAXBElement<>(new QName("http://springframework.org", "type"), MyType.class,
type);
processor.handleReturnValue(messageContext, supportedReturnType, element);
assertThat(messageContext.hasResponse()).isTrue();
AxiomSoapMessage response = (AxiomSoapMessage) messageContext.getResponse();
Transformer transformer = TransformerFactoryUtils.newInstance().newTransformer();
StringResult payloadResult = new StringResult();
transformer.transform(response.getPayloadSource(), payloadResult);
XmlAssert.assertThat(payloadResult.toString())
.and("<type xmlns='http://springframework.org'><string>Foo</string></type>").ignoreWhitespace().areIdentical();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
response.writeTo(bos);
String messageResult = bos.toString("UTF-8");
XmlAssert.assertThat(messageResult).and(
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Header/><soapenv:Body>"
+ "<type xmlns='http://springframework.org'><string>Foo</string></type>"
+ "</soapenv:Body></soapenv:Envelope>")
.ignoreWhitespace().areIdentical();
}
@ResponsePayload
public JAXBElement<MyType> supported(@RequestPayload JAXBElement<MyType> element) {
return element;

View File

@@ -18,16 +18,15 @@ package org.springframework.ws.server.endpoint.adapter.method.jaxb;
import static org.assertj.core.api.Assertions.*;
import java.io.ByteArrayOutputStream;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import java.io.OutputStream;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.sax.SAXSource;
import org.junit.jupiter.api.BeforeEach;
@@ -40,11 +39,7 @@ import org.springframework.ws.context.DefaultMessageContext;
import org.springframework.ws.context.MessageContext;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
import org.springframework.ws.soap.axiom.AxiomSoapMessage;
import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
import org.springframework.xml.sax.AbstractXmlReader;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.TransformerFactoryUtils;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -210,68 +205,6 @@ public class XmlRootElementPayloadMethodProcessorTest {
assertThat(messageContext.hasResponse()).isFalse();
}
@Test
public void handleReturnValueAxiom() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
MessageContext messageContext = new DefaultMessageContext(messageFactory);
MyRootElement rootElement = new MyRootElement();
rootElement.setString("Foo");
processor.handleReturnValue(messageContext, rootElementReturnType, rootElement);
assertThat(messageContext.hasResponse()).isTrue();
AxiomSoapMessage response = (AxiomSoapMessage) messageContext.getResponse();
Transformer transformer = TransformerFactoryUtils.newInstance().newTransformer();
StringResult payloadResult = new StringResult();
transformer.transform(response.getPayloadSource(), payloadResult);
XmlAssert.assertThat(payloadResult.toString())
.and("<root xmlns='http://springframework.org'><string>Foo</string></root>").ignoreWhitespace().areIdentical();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
response.writeTo(bos);
String messageResult = bos.toString("UTF-8");
XmlAssert.assertThat(messageResult).and(
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Header/><soapenv:Body>"
+ "<root xmlns='http://springframework.org'><string>Foo</string></root>"
+ "</soapenv:Body></soapenv:Envelope>")
.ignoreWhitespace().areIdentical();
}
@Test
public void handleReturnValueAxiomNoPayloadCaching() throws Exception {
AxiomSoapMessageFactory messageFactory = new AxiomSoapMessageFactory();
messageFactory.setPayloadCaching(false);
MessageContext messageContext = new DefaultMessageContext(messageFactory);
MyRootElement rootElement = new MyRootElement();
rootElement.setString("Foo");
processor.handleReturnValue(messageContext, rootElementReturnType, rootElement);
assertThat(messageContext.hasResponse()).isTrue();
AxiomSoapMessage response = (AxiomSoapMessage) messageContext.getResponse();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
response.writeTo(bos);
String messageResult = bos.toString("UTF-8");
XmlAssert.assertThat(messageResult).and(
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Header/><soapenv:Body>"
+ "<root xmlns='http://springframework.org'><string>Foo</string></root>"
+ "</soapenv:Body></soapenv:Envelope>")
.ignoreWhitespace().areIdentical();
}
@ResponsePayload
public MyRootElement rootElement(@RequestPayload MyRootElement rootElement) {
return rootElement;

View File

@@ -18,8 +18,9 @@ package org.springframework.ws.server.endpoint.interceptor;
import static org.assertj.core.api.Assertions.*;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.SOAPMessage;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;

View File

@@ -18,12 +18,13 @@ package org.springframework.ws.server.endpoint.mapping;
import static org.assertj.core.api.Assertions.*;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.SOAPMessage;
import java.lang.reflect.Method;
import java.util.Collections;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.transform.Source;
import org.apache.commons.logging.LogFactory;

View File

@@ -18,9 +18,10 @@ package org.springframework.ws.server.endpoint.mapping.jaxb;
import static org.assertj.core.api.Assertions.*;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.lang.reflect.Method;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;
import org.junit.jupiter.api.BeforeEach;

View File

@@ -18,14 +18,14 @@ package org.springframework.ws.soap.addressing;
import static org.assertj.core.api.Assertions.*;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.SOAPConstants;
import jakarta.xml.soap.SOAPException;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.ws.soap.saaj.SaajSoapMessage;
import org.w3c.dom.Document;

View File

@@ -18,14 +18,15 @@ package org.springframework.ws.soap.addressing.client;
import static org.easymock.EasyMock.*;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPBodyElement;
import jakarta.xml.soap.SOAPElement;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPMessage;
import java.net.URI;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

View File

@@ -18,14 +18,14 @@ package org.springframework.ws.soap.addressing.server;
import static org.assertj.core.api.Assertions.*;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.MimeHeaders;
import jakarta.xml.soap.SOAPConstants;
import jakarta.xml.soap.SOAPException;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.StaticApplicationContext;

Some files were not shown because too many files have changed in this diff Show More