Author: veithen
Date: Wed Oct 3 16:26:19 2012
New Revision: 1393588
URL: http://svn.apache.org/viewvc?rev=1393588&view=rev
Log:
* Added more message exchanges to the interoperability mock service.
* Fixed an issue in the GET handling in the java.net HTTP transport.
* Fixed a build failure on Java 1.5.
Added:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-1-response.xml
- copied unchanged from r1393525,
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-1-response-corrected.xml
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-3-response.xml
(with props)
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-request.xml
(with props)
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-response.xml
(with props)
Removed:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-1-response-corrected.xml
Modified:
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/main/java/org/apache/axis/transport/http/javanet/JavaNetHTTPSender.java
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/test/java/org/apache/axis/transport/http/javanet/TestGET.java
axis/axis1/java/trunk/axis-saaj/pom.xml
axis/axis1/java/trunk/interop-mock/pom.xml
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/DOMUtil.java
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/Exchange.java
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/README.txt
axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml
axis/axis1/java/trunk/pom.xml
Modified:
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/main/java/org/apache/axis/transport/http/javanet/JavaNetHTTPSender.java
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/main/java/org/apache/axis/transport/http/javanet/JavaNetHTTPSender.java?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
---
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/main/java/org/apache/axis/transport/http/javanet/JavaNetHTTPSender.java
(original)
+++
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/main/java/org/apache/axis/transport/http/javanet/JavaNetHTTPSender.java
Wed Oct 3 16:26:19 2012
@@ -36,6 +36,7 @@ import org.apache.axis.MessageContext;
import org.apache.axis.components.logger.LogFactory;
import org.apache.axis.encoding.Base64;
import org.apache.axis.handlers.BasicHandler;
+import org.apache.axis.soap.SOAP12Constants;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.commons.logging.Log;
@@ -62,6 +63,11 @@ public class JavaNetHTTPSender extends B
public void invoke(MessageContext msgContext) throws AxisFault {
try {
Message request = msgContext.getRequestMessage();
+ if (request != null &&
"GET".equals(msgContext.getStrProp(SOAP12Constants.PROP_WEBMETHOD))) {
+ // Always ignore the request message if the request is
explicitly marked as a GET request
+ request = null;
+ }
+
URL url = new URL(msgContext.getStrProp(MessageContext.TRANS_URL));
// Create and configure HttpURLConnection
Modified:
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/test/java/org/apache/axis/transport/http/javanet/TestGET.java
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/test/java/org/apache/axis/transport/http/javanet/TestGET.java?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
---
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/test/java/org/apache/axis/transport/http/javanet/TestGET.java
(original)
+++
axis/axis1/java/trunk/axis-rt-transports-http-javanet/src/test/java/org/apache/axis/transport/http/javanet/TestGET.java
Wed Oct 3 16:26:19 2012
@@ -30,7 +30,7 @@ import org.apache.axis.soap.SOAPConstant
import org.apache.axis.types.Time;
public class TestGET extends TestCase {
- public void test() throws Exception {
+ public void testXMLP2() throws Exception {
Call call = new Call("http://localhost:" +
System.getProperty("jetty.httpPort", "9080") + "/soap12/add-test-doc/getTime");
call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
call.setProperty(SOAP12Constants.PROP_WEBMETHOD, "GET");
@@ -41,4 +41,14 @@ public class TestGET extends TestCase {
Object result = env.getFirstBody().getValueAsType(Constants.XSD_TIME);
assertEquals(Time.class, result.getClass());
}
+
+ public void testXMLP3() throws Exception {
+ Call call = new Call("http://localhost:" +
System.getProperty("jetty.httpPort", "9080") + "/soap12/add-test-rpc/getTime");
+ call.setSOAPVersion(SOAPConstants.SOAP12_CONSTANTS);
+ call.setProperty(SOAP12Constants.PROP_WEBMETHOD, "GET");
+ call.setOperationStyle(Style.RPC);
+ call.setReturnType(Constants.XSD_TIME);
+ Object ret = call.invoke("", new Object [] {});
+ assertEquals(Time.class, ret.getClass());
+ }
}
Modified: axis/axis1/java/trunk/axis-saaj/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/axis-saaj/pom.xml?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
--- axis/axis1/java/trunk/axis-saaj/pom.xml (original)
+++ axis/axis1/java/trunk/axis-saaj/pom.xml Wed Oct 3 16:26:19 2012
@@ -31,7 +31,6 @@
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
- <version>1.1</version>
</dependency>
</dependencies>
<build>
Modified: axis/axis1/java/trunk/interop-mock/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/pom.xml?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
--- axis/axis1/java/trunk/interop-mock/pom.xml (original)
+++ axis/axis1/java/trunk/interop-mock/pom.xml Wed Oct 3 16:26:19 2012
@@ -41,6 +41,10 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
Modified:
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/DOMUtil.java
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/DOMUtil.java?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
---
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/DOMUtil.java
(original)
+++
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/DOMUtil.java
Wed Oct 3 16:26:19 2012
@@ -48,6 +48,10 @@ public final class DOMUtil {
private DOMUtil() {}
+ public static Document newDocument() {
+ return documentBuilder.newDocument();
+ }
+
public static Document parse(Resource resource) throws SAXException,
IOException {
InputStream in = resource.getInputStream();
try {
Modified:
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/Exchange.java
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/Exchange.java?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
---
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/Exchange.java
(original)
+++
axis/axis1/java/trunk/interop-mock/src/main/java/org/apache/axis/test/interop/mock/Exchange.java
Wed Oct 3 16:26:19 2012
@@ -29,6 +29,7 @@ import org.springframework.core.io.Resou
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
public class Exchange implements InitializingBean {
private static final Log log = LogFactory.getLog(Exchange.class);
@@ -68,7 +69,9 @@ public class Exchange implements Initial
Map<String,String> inferredVariables = new HashMap<String,String>();
if (match(requestMessage, root, inferredVariables)) {
log.debug("Message matches");
- return responseMessage;
+ Element clonedResponseMessage =
(Element)DOMUtil.newDocument().importNode(responseMessage, true);
+ substituteVariables(clonedResponseMessage, inferredVariables);
+ return clonedResponseMessage;
} else {
log.debug("Message doesn't match");
return null;
@@ -89,6 +92,13 @@ public class Exchange implements Initial
buffer.append(element.getLocalName());
}
+ /**
+ * Get the location of the given element as a pseudo XPath expression for
use in log messages.
+ *
+ * @param element
+ * the element
+ * @return the location of the element
+ */
private String getLocation(Element element) {
StringBuilder buffer = new StringBuilder();
getLocation(buffer, element);
@@ -96,6 +106,7 @@ public class Exchange implements Initial
}
private boolean match(Element expected, Element actual, Map<String,String>
inferredVariables) {
+ // Compare local name and namespace URI
if (!ObjectUtils.equals(expected.getLocalName(),
actual.getLocalName())) {
if (log.isDebugEnabled()) {
log.debug("Local name mismatch: expected=" +
expected.getLocalName() + "; actual=" + actual.getLocalName());
@@ -108,7 +119,10 @@ public class Exchange implements Initial
}
return false;
}
+
// TODO: compare attributes first
+
+ // Compare children
NodeList expectedChildren = expected.getChildNodes();
NodeList actualChildren = actual.getChildNodes();
if (expectedChildren.getLength() != actualChildren.getLength()) {
@@ -132,13 +146,71 @@ public class Exchange implements Initial
return false;
}
break;
+ case Node.TEXT_NODE:
+ if (!match((Text)expectedChild, (Text)actualChild,
inferredVariables)) {
+ return false;
+ }
+ break;
default:
if (log.isDebugEnabled()) {
- log.debug("Unexpected node type");
+ log.debug("Unexpected node type " +
expectedChild.getNodeType());
}
throw new IllegalStateException("Unexpected node type");
}
}
return true;
}
+
+ private boolean match(Text expected, Text actual, Map<String,String>
inferredVariables) {
+ String expectedContent = expected.getData();
+ String actualContent = actual.getData();
+ String varName = checkVariable(expectedContent);
+ if (varName != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Inferred variable: " + varName + "=" +
actualContent);
+ }
+ inferredVariables.put(varName, actualContent);
+ return true;
+ } else {
+ if (expectedContent.equals(actualContent)) {
+ return true;
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Text content mismatch at " +
getLocation((Element)expected.getParentNode())
+ + ": expected=" + expectedContent + "; actual=" +
actualContent);
+ }
+ return false;
+ }
+ }
+ }
+
+ private String checkVariable(String text) {
+ if (text.startsWith("@") && text.endsWith("@")) {
+ return text.substring(1, text.length()-1);
+ } else {
+ return null;
+ }
+ }
+
+ private void substituteVariables(Element element, Map<String,String>
variables) {
+ Node child = element.getFirstChild();
+ while (child != null) {
+ switch (child.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ substituteVariables((Element)child, variables);
+ break;
+ case Node.TEXT_NODE:
+ Text text = (Text)child;
+ String varName = checkVariable(text.getData());
+ if (varName != null) {
+ text.setData(variables.get(varName));
+ if (log.isDebugEnabled()) {
+ log.debug("Substituted variable " + varName + " at
" + getLocation(element));
+ }
+ }
+ break;
+ }
+ child = child.getNextSibling();
+ }
+ }
}
Modified: axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/README.txt
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/README.txt?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
--- axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/README.txt
(original)
+++ axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/README.txt Wed
Oct 3 16:26:19 2012
@@ -1,2 +1,10 @@
This folder contains request/responses extracted from SOAP Version 1.2
Specification Assertions and
-Test Collection (Second Edition). See
http://www.w3.org/TR/2007/REC-soap12-testcollection-20070427/.
\ No newline at end of file
+Test Collection (Second Edition; see
http://www.w3.org/TR/2007/REC-soap12-testcollection-20070427/),
+with corrections for the following mistakes in the spec:
+
+ * The response shown in XMLP-1 (second alternative) has incorrect namespace
prefixes for the fault
+ code and subcode values.
+ * Request messages for the echoSimpleTypesAsStruct operation use inputInt as
parameter name, but
+ in the description the parameter is called inputInteger (see XMLP-4).
+
+In addition, request values echoed in responses have been replaced by template
variables.
\ No newline at end of file
Added:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-3-response.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-3-response.xml?rev=1393588&view=auto
==============================================================================
---
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-3-response.xml
(added)
+++
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-3-response.xml
Wed Oct 3 16:26:19 2012
@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
+ <env:Body>
+ <sb:getTimeResponse xmlns:sb="http://soapinterop.org/"
+ xmlns:rpc="http://www.w3.org/2003/05/soap-rpc"
+ env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
+ <rpc:result>return</rpc:result>
+ <return>16:21:59Z</return>
+ </sb:getTimeResponse>
+ </env:Body>
+</env:Envelope>
\ No newline at end of file
Propchange:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-3-response.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-request.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-request.xml?rev=1393588&view=auto
==============================================================================
---
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-request.xml
(added)
+++
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-request.xml
Wed Oct 3 16:26:19 2012
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <sb:echoSimpleTypesAsStruct xmlns:sb="http://soapinterop.org/"
+ env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
+ <inputFloat xsi:type="xsd:float">@floatValue@</inputFloat>
+ <inputInteger xsi:type="xsd:int">@intValue@</inputInteger>
+ <inputString xsi:type="xsd:string">@stringValue@</inputString>
+ </sb:echoSimpleTypesAsStruct>
+ </env:Body>
+</env:Envelope>
\ No newline at end of file
Propchange:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-request.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-response.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-response.xml?rev=1393588&view=auto
==============================================================================
---
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-response.xml
(added)
+++
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-response.xml
Wed Oct 3 16:26:19 2012
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <env:Body>
+ <sb:echoSimpleTypesAsStructResponse xmlns:sb="http://soapinterop.org/"
+ xmlns:rpc="http://www.w3.org/2003/05/soap-rpc"
+ env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
+ <rpc:result>return</rpc:result>
+ <return xsi:type="ns1:SOAPStruct"
+ xmlns:ns1="http://soapinterop.org/xsd">
+ <varString xsi:type="xsd:string">@stringValue@</varString>
+ <varInt xsi:type="xsd:int">@intValue@</varInt>
+ <varFloat xsi:type="xsd:float">@floatValue@</varFloat>
+ </return>
+ </sb:echoSimpleTypesAsStructResponse>
+ </env:Body>
+</env:Envelope>
\ No newline at end of file
Propchange:
axis/axis1/java/trunk/interop-mock/src/main/resources/w3c/XMLP-4-response.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
---
axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml
(original)
+++
axis/axis1/java/trunk/interop-mock/src/main/webapp/WEB-INF/dispatcher-servlet.xml
Wed Oct 3 16:26:19 2012
@@ -22,13 +22,19 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="handlerMapping"
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
+ <!-- Endpoints that mock http://www.whitemesa.net -->
+
<bean name="/soap12/add-test-rpc"
class="org.apache.axis.test.interop.mock.MockPostHandler">
<property name="contentType" value="application/soap+xml"/>
<property name="exchanges">
<list>
<bean class="org.apache.axis.test.interop.mock.Exchange">
<property name="request"
value="classpath:w3c/XMLP-1-request.xml"/>
- <property name="response"
value="classpath:w3c/XMLP-1-response-corrected.xml"/>
+ <property name="response"
value="classpath:w3c/XMLP-1-response.xml"/>
+ </bean>
+ <bean class="org.apache.axis.test.interop.mock.Exchange">
+ <property name="request"
value="classpath:w3c/XMLP-4-request.xml"/>
+ <property name="response"
value="classpath:w3c/XMLP-4-response.xml"/>
</bean>
</list>
</property>
@@ -38,4 +44,9 @@
<property name="contentType" value="application/soap+xml"/>
<property name="response" value="classpath:w3c/XMLP-2-response.xml"/>
</bean>
+
+ <bean name="/soap12/add-test-rpc/getTime"
class="org.apache.axis.test.interop.mock.MockGetHandler">
+ <property name="contentType" value="application/soap+xml"/>
+ <property name="response" value="classpath:w3c/XMLP-3-response.xml"/>
+ </bean>
</beans>
Modified: axis/axis1/java/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis1/java/trunk/pom.xml?rev=1393588&r1=1393587&r2=1393588&view=diff
==============================================================================
--- axis/axis1/java/trunk/pom.xml (original)
+++ axis/axis1/java/trunk/pom.xml Wed Oct 3 16:26:19 2012
@@ -76,6 +76,11 @@
<dependencyManagement>
<dependencies>
<dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>