Author: jim.ma
Date: 2010-03-02 01:40:27 -0500 (Tue, 02 Mar 2010)
New Revision: 11704
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpoint.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpointImpl.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/JBWS2927TestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2927/request-message.xml
Log:
[JBWS-2927]:Make WSAAddressingServerHandler and WSAAddressingClientHandler honore the
required value in @Addressing annotation
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java 2010-03-01
14:20:47 UTC (rev 11703)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java 2010-03-02
06:40:27 UTC (rev 11704)
@@ -24,6 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
import org.jboss.ws.extensions.addressing.soap.SOAPAddressingPropertiesImpl;
+import org.jboss.ws.metadata.umdm.ClientEndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.wsf.common.handler.GenericSOAPHandler;
@@ -41,6 +42,7 @@
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.MessageContext.Scope;
import javax.xml.ws.handler.soap.SOAPMessageContext;
+import javax.xml.ws.soap.AddressingFeature;
import java.net.URISyntaxException;
import java.util.Collections;
@@ -137,8 +139,22 @@
{
SOAPAddressingBuilder builder =
(SOAPAddressingBuilder)SOAPAddressingBuilder.getAddressingBuilder();
SOAPAddressingProperties addrProps =
(SOAPAddressingProperties)builder.newAddressingProperties();
- soapMessage.setProperty("isClientInbound", "true");
- addrProps.readHeaders(soapMessage);
+ CommonMessageContext commonMsgContext =
(CommonMessageContext)msgContext;
+ ClientEndpointMetaData serverMetaData =
(ClientEndpointMetaData)commonMsgContext.getEndpointMetaData();
+ AddressingFeature addrFeature =
serverMetaData.getFeature(AddressingFeature.class);
+ if (addrFeature != null && addrFeature.isRequired())
+ {
+ try
+ {
+ soapMessage.setProperty("isRequired", true);
+ }
+ catch (Exception e)
+ {
+ //ignore
+ }
+
+ }
+ addrProps.readHeaders(soapMessage);
msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProps);
msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES,
Scope.APPLICATION);
msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND,
addrProps);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java 2010-03-01
14:20:47 UTC (rev 11703)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java 2010-03-02
06:40:27 UTC (rev 11704)
@@ -26,6 +26,7 @@
import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
import org.jboss.ws.extensions.addressing.metadata.AddressingOpMetaExt;
import org.jboss.ws.metadata.umdm.OperationMetaData;
+import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.wsf.common.handler.GenericSOAPHandler;
import org.w3c.dom.Element;
@@ -38,6 +39,8 @@
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.MessageContext.Scope;
import javax.xml.ws.handler.soap.SOAPMessageContext;
+import javax.xml.ws.soap.AddressingFeature;
+
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashSet;
@@ -82,7 +85,22 @@
SOAPAddressingProperties addrProps =
(SOAPAddressingProperties)ADDR_BUILDER.newAddressingProperties();
SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
- addrProps.readHeaders(soapMessage);
+ CommonMessageContext commonMsgContext = (CommonMessageContext)msgContext;
+ ServerEndpointMetaData serverMetaData =
(ServerEndpointMetaData)commonMsgContext.getEndpointMetaData();
+ AddressingFeature addrFeature =
serverMetaData.getFeature(AddressingFeature.class);
+ if (addrFeature != null && addrFeature.isRequired())
+ {
+ try
+ {
+ soapMessage.setProperty("isRequired", true);
+ }
+ catch (Exception e)
+ {
+ //ignore
+ }
+
+ }
+ addrProps.readHeaders(soapMessage);
msgContext.put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND, addrProps);
msgContext.setScope(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND,
Scope.APPLICATION);
msgContext.put(MessageContext.REFERENCE_PARAMETERS,
convertToElementList(addrProps.getReferenceParameters().getElements()));
@@ -138,7 +156,7 @@
msgContext.setScope(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND,
Scope.APPLICATION);
}
- outProps.initializeAsReply(inProps, isFault);
+ if (inProps != null) outProps.initializeAsReply(inProps, isFault);
try
{
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java 2010-03-01
14:20:47 UTC (rev 11703)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java 2010-03-02
06:40:27 UTC (rev 11704)
@@ -104,7 +104,7 @@
try
{
SOAPHeader soapHeader = message.getSOAPHeader();
-
+
SOAPAddressingBuilder builder = new SOAPAddressingBuilderImpl();
AddressingConstants ADDR = builder.newAddressingConstants();
registerNamespaces(ADDR, soapHeader);
@@ -150,18 +150,16 @@
// wsa:Action
// This REQUIRED element of type xs:anyURI conveys the [action] property.
// The [children] of this element convey the value of this property.
- if (message.getProperty("isClientInbound") != null)
+ if (message.getProperty("isRequired") != null &&
(Boolean)message.getProperty("isRequired"))
{
- String action = getOptionalHeaderContent(soapHeader,
ADDR.getActionQName());
- if (action != null)
- {
- setAction(builder.newURI(action));
- }
- }
+ //check the action header only if the required value is true
+ String action = getRequiredHeaderContent(soapHeader,
ADDR.getActionQName());
+ setAction(builder.newURI(action));
+ }
else
{
- String action = getRequiredHeaderContent(soapHeader,
ADDR.getActionQName());
- setAction(builder.newURI(action));
+ String action = getOptionalHeaderContent(soapHeader,
ADDR.getActionQName());
+ if (action != null) setAction(builder.newURI(action));
}
// Read wsa:MessageID
Modified: stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2010-03-01
14:20:47 UTC (rev 11703)
+++
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2010-03-02
06:40:27 UTC (rev 11704)
@@ -596,6 +596,17 @@
<include name="jboss-web.xml"/>
</webinf>
</war>
+
+ <!-- jaxws-jbws2927 -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-jbws2927.war"
webxml="${tests.output.dir}/test-resources/jaxws/jbws2927/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/jbws2927/*.class"/>
+ <exclude
name="org/jboss/test/ws/jaxws/jbws2927/JBWS2927TestCase.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2927/WEB-INF">
+ <include name="jboss-web.xml"/>
+ </webinf>
+ </war>
<!-- jaxws-webserviceref -->
<war warfile="${tests.output.dir}/test-libs/jaxws-webserviceref.war"
webxml="${tests.output.dir}/test-resources/jaxws/webserviceref/WEB-INF/web.xml">
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/JBWS2927TestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/JBWS2927TestCase.java 2010-03-01
14:20:47 UTC (rev 11703)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/JBWS2927TestCase.java 2010-03-02
06:40:27 UTC (rev 11704)
@@ -22,18 +22,33 @@
package org.jboss.test.ws.jaxws.jbws2927;
import java.net.URL;
+import java.util.Iterator;
+import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.addressing.JAXWSAConstants;
+import junit.framework.Test;
+
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
+import org.jboss.ws.core.jaxws.spi.EndpointImpl;
+import org.jboss.ws.core.soap.NodeImpl;
import org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler;
import org.jboss.ws.extensions.addressing.soap.SOAPAddressingPropertiesImpl;
+import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* A JBWS2927TestCase.
@@ -42,22 +57,66 @@
*/
public class JBWS2927TestCase extends JBossWSTest
{
- public void testHandleInboundMessage() throws Exception
+
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-jbws2927";
+
+ private static WSAEndpoint port;
+
+ public static Test suite() throws Exception
{
- WSAddressingClientHandler wsHandler = new WSAddressingClientHandler();
- SOAPMessageContextJAXWS context = new SOAPMessageContextJAXWS();
- context.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, new Boolean(false));
- context.put(BindingProvider.SOAPACTION_URI_PROPERTY, "inputAction");
- context.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, new
SOAPAddressingPropertiesImpl());
- context.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, new
SOAPAddressingPropertiesImpl());
- MessageFactory factory = MessageFactory.newInstance();
-
+ return new JBossWSTestSetup(JBWS2927TestCase.class,
"jaxws-jbws2927.war");
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new
QName("http://ws.jboss.org/jbws2927",
"WSAEndpointService");
+
+ Service service = Service.create(wsdlURL, serviceName);
+ port = service.getPort(WSAEndpoint.class);
+ }
+
+ public void testCall() throws Exception
+ {
+ String response = port.echo("testJBWS2927");
+ assertEquals("testJBWS2927", response);
+ }
+
+ public void testSOAPRequestWithoutWsaHeader() throws Exception
+ {
+ SOAPMessage reqMsg = getRequestMessage();
+ URL epURL = new URL(TARGET_ENDPOINT_ADDRESS);
+ SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
+ SOAPMessage resMsg = con.call(reqMsg, epURL);
+ SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
+
+ String response = "";
+
+ SOAPBody body = resEnv.getBody();
+ Iterator it = body.getChildElements(new
QName("http://ws.jboss.org/jbws2927", "echoResponse"));
+ Node node = (Node)it.next();
+ NodeList nodes = node.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++)
+ {
+ Node current = nodes.item(i);
+ if (current.getNodeName().equals("return"))
+ {
+ response = ((NodeImpl)current).getValue();
+ }
+ }
+
+ // The logical handler should have replaced the incoming String.
+ assertEquals("testJBWS2927", response);
+ }
+
+ private SOAPMessage getRequestMessage() throws Exception
+ {
URL reqMessage =
getResourceFile("jaxws/jbws2927/request-message.xml").toURL();
MessageFactory msgFactory = MessageFactory.newInstance();
- SOAPMessage soapMsg = msgFactory.createMessage(null, reqMessage.openStream());
- context.setMessage(soapMsg);
-
- wsHandler.handleMessage(context);
+ SOAPMessage reqMsg = msgFactory.createMessage(null, reqMessage.openStream());
+ return reqMsg;
}
-}
+
+}
\ No newline at end of file
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpoint.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpoint.java
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpoint.java 2010-03-02
06:40:27 UTC (rev 11704)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2927;
+
+import javax.jws.WebService;
+import javax.xml.ws.Action;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.SOAPBinding;
+
+@WebService(name = "WSAEndpoint", targetNamespace =
"http://ws.jboss.org/jbws2927")
+@BindingType(value = SOAPBinding.SOAP11HTTP_BINDING)
+@Addressing(enabled = true, required = false)
+public interface WSAEndpoint
+{
+ @Action(input = "inputAction", output = "outputAction")
+ public String echo(String message);
+}
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpointImpl.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpointImpl.java
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2927/WSAEndpointImpl.java 2010-03-02
06:40:27 UTC (rev 11704)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.jbws2927;
+
+import javax.jws.WebService;
+import javax.xml.ws.Action;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.SOAPBinding;
+
+@WebService(name = "WSAEndpoint", portName = "WSAEndpointPort",
serviceName="WSAEndpointService", targetNamespace =
"http://ws.jboss.org/jbws2927", endpointInterface =
"org.jboss.test.ws.jaxws.jbws2927.WSAEndpoint")
+@BindingType(value = SOAPBinding.SOAP11HTTP_BINDING)
+@Addressing(enabled = true, required = false)
+public class WSAEndpointImpl implements WSAEndpoint
+{
+ @Action(input = "inputAction", output = "outputAction")
+ public String echo(String message)
+ {
+
+ return message;
+ }
+
+}
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java 2010-03-01
14:20:47 UTC (rev 11703)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java 2010-03-02
06:40:27 UTC (rev 11704)
@@ -150,8 +150,8 @@
public void testReplyToWithoutAction() throws Exception
{
MessageFactory mf = MessageFactory.newInstance();
- SOAPMessage message = mf.createMessage(null, new
ByteArrayInputStream(ERRORNOUS_XML.getBytes()));
-
+ SOAPMessage message= mf.createMessage(null, new
ByteArrayInputStream(ERRORNOUS_XML.getBytes()));
+ message.setProperty("isRequired", true);
SOAPAddressingPropertiesImpl props = new SOAPAddressingPropertiesImpl();
try
{
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2927/request-message.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2927/request-message.xml 2010-03-01
14:20:47 UTC (rev 11703)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/jaxws/jbws2927/request-message.xml 2010-03-02
06:40:27 UTC (rev 11704)
@@ -1,6 +1 @@
-<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:jbw="http://ws.jboss.org/jbws2927">
- <soapenv:Header/>
- <soapenv:Body>
-
<jbw:addNumbersResponse><return>20</return><arg0>ClientEnabledServerNotEnabled</arg0></jbw:addNumbersResponse>
- </soapenv:Body>
-</soapenv:Envelope>
+<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:...
xmlns:ns2="http://ws.jboss.org/jbws2927"><arg0>testJBW...
\ No newline at end of file