Author: palin
Date: 2007-04-24 04:30:31 -0400 (Tue, 24 Apr 2007)
New Revision: 2913
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLExtensibilityElement.java
branches/JBWS-856/jbossws-tests/src/resources/common/wsdl11/PolicyAttachment.wsdl
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/Constants.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBinding.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperation.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java
Log:
Modified the unmarshalling of wsdl 1.1 to the unified wsdl structure in order to collect
eventual policy attachment in wsdl extensibility elements/attributes.
Modified: branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/Constants.java
===================================================================
--- branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/Constants.java 2007-04-24
06:35:57 UTC (rev 2912)
+++ branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/Constants.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -100,6 +100,9 @@
/** WS-Eventing namespace uri **/
static final String URI_WS_EVENTING =
"http://schemas.xmlsoap.org/ws/2004/08/eventing";
+ /** WS-Policy namespace uri **/
+ static final String URI_WS_POLICY =
"http://schemas.xmlsoap.org/ws/2004/09/policy";
+
/** WS-Addressing namespace uri **/
static final String URI_WS_ADDRESSING =
"http://www.w3.org/2005/08/addressing";
@@ -276,6 +279,10 @@
static final String WSDL_PROPERTY_ACTION_OUT =
"http://www.jboss.org/jbossws/wsa/actionOut";
static final String WSDL_PROPERTY_EVENTSOURCE =
"http://www.jboss.org/jbossws/wse/isEventSource";
+
+ static final String WSDL_ELEMENT_POLICY =
"http://www.jboss.org/jbossws/wsp/policy";
+ static final String WSDL_PROPERTY_POLICYURIS =
"http://www.jboss.org/jbossws/wsp/policyURIs";
+ static final String WSDL_ELEMENT_POLICYREFERENCE =
"http://www.jboss.org/jbossws/wsp/policyReference";
/** The key to the original message part name */
static final String WSDL_PROPERTY_PART_NAME =
"http://www.jboss.org/jbossws/partname";
@@ -293,7 +300,9 @@
static final QName WSDL_ATTRIBUTE_WSA_ACTION = new QName(URI_WS_ADDRESSING,
"Action");
static final QName WSDL_ATTRIBUTE_WSE_EVENTSOURCE = new QName(URI_WS_EVENTING,
"EventSource");
-
+
+ static final QName WSDL_ATTRIBUTE_WSP_POLICYURIS = new QName(URI_WS_POLICY,
"PolicyURIs");
+
/** WSDL-2.0 exchange patterns */
static final String WSDL20_PATTERN_IN_ONLY =
"http://www.w3.org/2004/08/wsdl/in-only";
static final String WSDL20_PATTERN_ROUST_IN_ONLY =
"http://www.w3.org/2004/08/wsdl/robust-in-only";
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java 2007-04-24
06:35:57 UTC (rev 2912)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/Extendable.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -26,6 +26,8 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import org.jboss.logging.Logger;
@@ -43,6 +45,7 @@
private Map features = new LinkedHashMap();
private Map properties = new LinkedHashMap();
+ private Map<String,List<WSDLExtensibilityElement>> extElements = new
LinkedHashMap<String,List<WSDLExtensibilityElement>>();
public WSDLFeature[] getFeatures()
{
@@ -83,4 +86,32 @@
WSDLProperty property = (WSDLProperty)properties.get(uri);
return property;
}
+
+ public void addExtensibilityElement(WSDLExtensibilityElement extElement)
+ {
+ log.trace("addExtensibilityElement: " + extElement);
+ String uri = extElement.getUri();
+ List<WSDLExtensibilityElement> list = extElements.get(uri);
+ if (list == null)
+ {
+ list = new LinkedList<WSDLExtensibilityElement>();
+ extElements.put(uri,list);
+ }
+ list.add(extElement);
+ }
+
+ public List<WSDLExtensibilityElement> getExtensibilityElements(String uri)
+ {
+ return extElements.get(uri);
+ }
+
+ public List<WSDLExtensibilityElement> getAllExtensibilityElements()
+ {
+ List<WSDLExtensibilityElement> list = new
LinkedList<WSDLExtensibilityElement>();
+ for (String k : extElements.keySet())
+ {
+ list.addAll(extElements.get(k));
+ }
+ return list;
+ }
}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBinding.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBinding.java 2007-04-24
06:35:57 UTC (rev 2912)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBinding.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -40,7 +40,7 @@
* @author <a href="jason.greene(a)jboss.com">Jason T. Greene</a>
* @since 10-Oct-2004
*/
-public class WSDLBinding implements Serializable
+public class WSDLBinding extends Extendable implements Serializable
{
private static final long serialVersionUID = -7699953670233209811L;
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java 2007-04-24
06:35:57 UTC (rev 2912)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingMessageReference.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -34,7 +34,7 @@
* @author <a href="mailto:jason.greene@jboss.com">Jason T.
Greene</a>
* @version $Revision$
*/
-public abstract class WSDLBindingMessageReference
+public abstract class WSDLBindingMessageReference extends Extendable
{
// The parent WSDL binding operation
private WSDLBindingOperation wsdlBindingOperation;
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperation.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperation.java 2007-04-24
06:35:57 UTC (rev 2912)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLBindingOperation.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -41,7 +41,7 @@
* @author Anil.Saldhana(a)jboss.org
* @since 10-Oct-2004
*/
-public class WSDLBindingOperation implements Comparable, Serializable
+public class WSDLBindingOperation extends Extendable implements Comparable, Serializable
{
private static final long serialVersionUID = -1986624862746844610L;
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java 2007-04-24
06:35:57 UTC (rev 2912)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLDefinitions.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -47,7 +48,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 10-Oct-2004
*/
-public class WSDLDefinitions implements Serializable
+public class WSDLDefinitions extends Extendable implements Serializable
{
private static final long serialVersionUID = 1643422922694990226L;
@@ -209,7 +210,7 @@
{
includes.add(include);
}
-
+
public WSDLTypes getWsdlTypes()
{
return types;
Added:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLExtensibilityElement.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLExtensibilityElement.java
(rev 0)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/metadata/wsdl/WSDLExtensibilityElement.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ws.metadata.wsdl;
+
+import java.io.Serializable;
+
+import org.w3c.dom.Element;
+
+/**
+ * Common metadata for (unknown) wsdl extensibility elements
+ *
+ * @author Alessio Soldano, <alessio.soldano(a)javalinux.it>
+ * @since 24-Apr-2007
+ *
+ */
+public class WSDLExtensibilityElement implements Serializable
+{
+ private static final long serialVersionUID = -7528676719881753461L;
+
+ /** A REQUIRED uri attribute information item */
+ private String uri;
+ /** An OPTIONAL required attribute information item */
+ private boolean required;
+
+ private Element element;
+
+ public WSDLExtensibilityElement(String uri, Element element)
+ {
+ this.element = element;
+ this.uri = uri;
+ }
+
+ public Element getElement()
+ {
+ return element;
+ }
+
+ public void setElement(Element element)
+ {
+ this.element = element;
+ }
+
+ public boolean isRequired()
+ {
+ return required;
+ }
+
+ public void setRequired(boolean required)
+ {
+ this.required = required;
+ }
+
+ public String getUri()
+ {
+ return uri;
+ }
+
+ public void setUri(String uri)
+ {
+ this.uri = uri;
+ }
+
+}
Modified:
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
===================================================================
---
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2007-04-24
06:35:57 UTC (rev 2912)
+++
branches/JBWS-856/jbossws-core/src/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -53,6 +53,7 @@
import javax.wsdl.Service;
import javax.wsdl.Types;
import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ElementExtensible;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.UnknownExtensibilityElement;
import javax.wsdl.extensions.mime.MIMEContent;
@@ -76,6 +77,7 @@
import org.jboss.ws.core.utils.DOMUtils;
import org.jboss.ws.core.utils.DOMWriter;
import org.jboss.ws.core.utils.ResourceURL;
+import org.jboss.ws.metadata.wsdl.Extendable;
import org.jboss.ws.metadata.wsdl.WSDLBinding;
import org.jboss.ws.metadata.wsdl.WSDLBindingMessageReference;
import org.jboss.ws.metadata.wsdl.WSDLBindingOperation;
@@ -83,6 +85,7 @@
import org.jboss.ws.metadata.wsdl.WSDLBindingOperationOutput;
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
import org.jboss.ws.metadata.wsdl.WSDLInterface;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceFault;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
@@ -156,6 +159,7 @@
processNamespaces(srcWsdl);
processTypes(srcWsdl, wsdlLoc);
+ processUnknownExtensibilityElements(srcWsdl, destWsdl);
processServices(srcWsdl);
if (getAllDefinedBindings(srcWsdl).size() != destWsdl.getBindings().length)
@@ -209,6 +213,41 @@
destWsdl.registerNamespaceURI(nsURI, prefix);
}
}
+
+ private void processUnknownExtensibilityElements(ElementExtensible src, Extendable
dest) throws WSDLException
+ {
+ List extElements = src.getExtensibilityElements();
+ for (int i=0; i<extElements.size(); i++)
+ {
+ ExtensibilityElement extElement = (ExtensibilityElement)extElements.get(i);
+ processPolicyElements(extElement, dest);
+ //add processing of further extensibility element types below
+ }
+ }
+
+ private void processPolicyElements(ExtensibilityElement extElement, Extendable dest)
+ {
+ if (extElement instanceof UnknownExtensibilityElement)
+ {
+ Element srcElement = ((UnknownExtensibilityElement)extElement).getElement();
+ if (Constants.URI_WS_POLICY.equals(srcElement.getNamespaceURI()))
+ {
+ Element element = (Element)srcElement.cloneNode(true);
+ copyParentNamespaceDeclarations(element,srcElement);
+ if (element.getLocalName().equals("Policy"))
+ {
+ dest.addExtensibilityElement(
+ new
WSDLExtensibilityElement(Constants.WSDL_ELEMENT_POLICY,element));
+ }
+ else if (element.getLocalName().equals("PolicyReference"))
+ {
+ dest.addExtensibilityElement(
+ new
WSDLExtensibilityElement(Constants.WSDL_ELEMENT_POLICYREFERENCE,element));
+ }
+
+ }
+ }
+ }
private void processTypes(Definition srcWsdl, URL wsdlLoc) throws IOException,
WSDLException
{
@@ -465,7 +504,14 @@
if (destWsdl.getInterface(qname) == null)
{
WSDLInterface destInterface = new WSDLInterface(destWsdl, qname);
-
+
+ //policy extensions
+ QName policyURIsProp =
(QName)srcPortType.getExtensionAttribute(Constants.WSDL_ATTRIBUTE_WSP_POLICYURIS);
+ if (policyURIsProp != null &&
!"".equalsIgnoreCase(policyURIsProp.getLocalPart()))
+ {
+ destInterface.addProperty(new
WSDLProperty(Constants.WSDL_PROPERTY_POLICYURIS, policyURIsProp.getLocalPart()));
+ }
+
// eventing extensions
QName eventSourceProp =
(QName)srcPortType.getExtensionAttribute(Constants.WSDL_ATTRIBUTE_WSE_EVENTSOURCE);
if (eventSourceProp != null &&
eventSourceProp.getLocalPart().equals(Boolean.TRUE.toString()))
@@ -487,6 +533,7 @@
Operation srcOperation = (Operation)itOperations.next();
WSDLInterfaceOperation destOperation = new WSDLInterfaceOperation(destInterface,
srcOperation.getName());
+ processUnknownExtensibilityElements(srcOperation, destOperation);
destOperation.setStyle(getOperationStyle(srcWsdl, srcPortType, srcOperation));
if (srcOperation.getStyle() != null && false ==
OperationType.NOTIFICATION.equals(srcOperation.getStyle()))
@@ -545,6 +592,7 @@
destOperation.addProperty(new
WSDLProperty(Constants.WSDL_PROPERTY_MESSAGE_NAME_IN,
srcMessage.getQName().getLocalPart()));
destInput.setPartName(srcPart.getName());
+ processUnknownExtensibilityElements(srcMessage, destInput);
destOperation.addInput(destInput);
}
@@ -565,6 +613,7 @@
// WSDL 2.0 RPC bindings
rpcInput.setElement(destOperation.getName());
rpcInput.setMessageName(srcMessage.getQName());
+ processUnknownExtensibilityElements(srcMessage, rpcInput);
destOperation.addInput(rpcInput);
}
}
@@ -861,6 +910,7 @@
WSDLBinding destBinding = new WSDLBinding(destWsdl, srcBindingQName);
destBinding.setInterfaceName(srcPortType.getQName());
destBinding.setType(bindingType);
+ processUnknownExtensibilityElements(srcBinding, destBinding);
destWsdl.addBinding(destBinding);
// mark SWA Parts upfront
@@ -1011,6 +1061,7 @@
WSDLBindingOperation destBindingOperation = new WSDLBindingOperation(destBinding);
QName refQName = new QName(namespaceURI, srcOperationName);
destBindingOperation.setRef(refQName);
+ processUnknownExtensibilityElements(srcBindingOperation, destBindingOperation);
destBinding.addOperation(destBindingOperation);
String opName = srcOperationName;
@@ -1061,6 +1112,7 @@
List<ExtensibilityElement> extList =
srcBindingInput.getExtensibilityElements();
WSDLBindingOperationInput input = new
WSDLBindingOperationInput(destBindingOperation);
+ processUnknownExtensibilityElements(srcBindingInput, input);
destBindingOperation.addInput(input);
ReferenceCallback cb = new ReferenceCallback() {
@@ -1284,6 +1336,7 @@
Service srcService = (Service)it.next();
QName qname = srcService.getQName();
WSDLService destService = new WSDLService(destWsdl, qname);
+ processUnknownExtensibilityElements(srcService, destService);
destWsdl.addService(destService);
processPorts(srcWsdl, destService, srcService);
}
@@ -1328,6 +1381,7 @@
WSDLEndpoint destEndpoint = new WSDLEndpoint(destService, endpointName);
destEndpoint.setBinding(srcBinding.getQName());
destEndpoint.setAddress(getSOAPAddress(srcPort));
+ processUnknownExtensibilityElements(srcPort, destEndpoint);
if (processBinding(srcWsdl, srcBinding))
destService.addEndpoint(destEndpoint);
Modified:
branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java
===================================================================
---
branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java 2007-04-24
06:35:57 UTC (rev 2912)
+++
branches/JBWS-856/jbossws-tests/src/java/org/jboss/test/ws/common/wsdl11/WSDL11TestCase.java 2007-04-24
08:30:31 UTC (rev 2913)
@@ -22,23 +22,28 @@
package org.jboss.test.ws.common.wsdl11;
import java.io.File;
+import java.util.List;
import javax.xml.namespace.QName;
import org.jboss.test.ws.JBossWSTest;
import org.jboss.ws.Constants;
import org.jboss.ws.extensions.eventing.EventingConstants;
+import org.jboss.ws.metadata.wsdl.WSDLBinding;
import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
import org.jboss.ws.metadata.wsdl.WSDLInterface;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperation;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationInput;
import org.jboss.ws.metadata.wsdl.WSDLInterfaceOperationOutput;
+import org.jboss.ws.metadata.wsdl.WSDLProperty;
import org.jboss.ws.metadata.wsdl.WSDLRPCPart;
import org.jboss.ws.metadata.wsdl.WSDLService;
import org.jboss.ws.metadata.wsdl.WSDLTypes;
import org.jboss.ws.metadata.wsdl.WSDLUtils;
import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
+import org.w3c.dom.Element;
/**
* Test the unmarshalling of wsdl-1.1 into the unified wsdl structure
@@ -182,4 +187,76 @@
WSDLDefinitions wsdlDefinitions = factory.parse(wsdlFile.toURL());
assertNotNull(wsdlDefinitions); // should throw an Exception when SWA parts are not
skipped
}
+
+ public void testPolicyAttachment() throws Exception
+ {
+ File wsdlFile = new
File("resources/common/wsdl11/PolicyAttachment.wsdl");
+ assertTrue(wsdlFile.exists());
+
+ WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
+ WSDLDefinitions wsdlDefinitions = factory.parse(wsdlFile.toURL());
+ assertNotNull(wsdlDefinitions);
+ List<WSDLExtensibilityElement> list =
wsdlDefinitions.getExtensibilityElements(Constants.WSDL_ELEMENT_POLICY);
+ assertNotNull(list);
+ assertEquals(list.size(),5);
+ for (WSDLExtensibilityElement extEl : list)
+ {
+ Element el = extEl.getElement();
+ assertNotNull(el);
+ QName qName = new QName(el.getNamespaceURI(),el.getLocalName(),el.getPrefix());
+ assertEquals(qName,new
QName("http://schemas.xmlsoap.org/ws/2004/09/policy","Poli...);
+
assertNotNull(el.getAttributeNodeNS("http://docs.oasis-open.org/wss/...;
+ //System.out.println(DOMWriter.printNode(extEl.getElement(),true));
+ }
+ }
+
+ public void testServicePolicyRef() throws Exception
+ {
+ File wsdlFile = new
File("resources/common/wsdl11/PolicyAttachment.wsdl");
+ WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
+ WSDLDefinitions wsdlDefinitions = factory.parse(wsdlFile.toURL());
+ WSDLService wsdlService = wsdlDefinitions.getServices()[0];
+ List<WSDLExtensibilityElement> list = wsdlService.getExtensibilityElements(
+ Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ assertNotNull(list);
+ assertEquals(list.size(),1);
+ assertPolicyRef(list.get(0),"uselessServicePolicy");
+ }
+
+ public void testEndpointPolicyRef() throws Exception
+ {
+ File wsdlFile = new
File("resources/common/wsdl11/PolicyAttachment.wsdl");
+ WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
+ WSDLDefinitions wsdlDefinitions = factory.parse(wsdlFile.toURL());
+ WSDLService wsdlService = wsdlDefinitions.getServices()[0];
+ WSDLEndpoint wsdlEndpoint = wsdlService.getEndpoints()[0];
+
+ List<WSDLExtensibilityElement> extPortList =
wsdlEndpoint.getExtensibilityElements(
+ Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ assertNotNull(extPortList);
+ assertEquals(extPortList.size(),1);
+ assertPolicyRef(extPortList.get(0),"uselessPortPolicy");
+
+ WSDLProperty extPortTypeProp = wsdlEndpoint.getInterface().getProperty(
+ Constants.WSDL_PROPERTY_POLICYURIS);
+ assertEquals(extPortTypeProp.getValue(),"#RmPolicy");
+
+ WSDLBinding wsdlBinding = wsdlDefinitions.getBinding(wsdlEndpoint.getBinding());
+ List<WSDLExtensibilityElement> extBinding =
wsdlBinding.getExtensibilityElements(
+ Constants.WSDL_ELEMENT_POLICYREFERENCE);
+ assertNotNull(extBinding);
+ assertEquals(extBinding.size(),2);
+ assertPolicyRef(extBinding.get(0),"RmPolicy");
+ assertPolicyRef(extBinding.get(1),"X509EndpointPolicy");
+ }
+
+
+ private void assertPolicyRef(WSDLExtensibilityElement extEl, String policyURI)
+ {
+ Element el = extEl.getElement();
+ QName qName = new QName(el.getNamespaceURI(),el.getLocalName(),el.getPrefix());
+ assertEquals(qName,new
QName("http://schemas.xmlsoap.org/ws/2004/09/policy","Poli...);
+ assertNotNull(el);
+
assertEquals(el.getAttributeNode("URI").getValue(),"#"+policyURI);
+ }
}
Added: branches/JBWS-856/jbossws-tests/src/resources/common/wsdl11/PolicyAttachment.wsdl
===================================================================
--- branches/JBWS-856/jbossws-tests/src/resources/common/wsdl11/PolicyAttachment.wsdl
(rev 0)
+++
branches/JBWS-856/jbossws-tests/src/resources/common/wsdl11/PolicyAttachment.wsdl 2007-04-24
08:30:31 UTC (rev 2913)
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<definitions name="TestService"
targetNamespace="http://org.jboss.ws/jaxrpc"
+ xmlns:tns="http://org.jboss.ws/jaxrpc"
+
xmlns="http://schemas.xmlsoap.org/wsdl/"
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:ns2="http://org.jboss.ws/jaxrpc/types"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+
xmlns:fab="http://www.fabrikam123.example.com/stock"
+
xmlns:rmp="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
+
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
+
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-w...
>
+ <wsp:Policy wsu:Id="RmPolicy" >
+ <rmp:RMAssertion>
+ <rmp:InactivityTimeout Milliseconds="600000" />
+ <rmp:BaseRetransmissionInterval Milliseconds="3000" />
+ <rmp:ExponentialBackoff />
+ <rmp:AcknowledgementInterval Milliseconds="200" />
+ </rmp:RMAssertion>
+ </wsp:Policy>
+ <wsp:Policy wsu:Id="uselessServicePolicy" >
+ <fab:useless>nothing</fab:useless>
+ </wsp:Policy>
+ <wsp:Policy wsu:Id="uselessPortPolicy" >
+ <fab:useless>nothing again</fab:useless>
+ </wsp:Policy>
+ <wsp:Policy wsu:Id="X509EndpointPolicy" >
+ <sp:AsymmetricBinding>
+ <wsp:Policy>
+ <!-- Details omitted for readability -->
+ <sp:IncludeTimestamp />
+ <sp:OnlySignEntireHeadersAndBody />
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ </wsp:Policy>
+ <wsp:Policy wsu:Id="SecureMessagePolicy" >
+ <sp:SignedParts>
+ <sp:Body />
+ </sp:SignedParts>
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ </wsp:Policy>
+ <types>
+ <schema targetNamespace="http://org.jboss.ws/jaxrpc/types"
xmlns:tns="http://org.jboss.ws/jaxrpc/types"
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="echoSimpleUserType">
+ <sequence>
+ <element name="String_1" type="string"
nillable="true"/>
+ <element name="SimpleUserType_2"
type="tns:SimpleUserType" nillable="true"/>
+ </sequence>
+ </complexType>
+ <complexType name="SimpleUserType">
+ <sequence>
+ <element name="a" type="int"/>
+ <element name="b" type="int"/>
+ </sequence>
+ </complexType>
+ <complexType name="echoSimpleUserTypeResponse">
+ <sequence>
+ <element name="result" type="tns:SimpleUserType"
nillable="true"/>
+ </sequence>
+ </complexType>
+ <complexType name="echoString">
+ <sequence>
+ <element name="String_1" type="string"
nillable="true"/>
+ <element name="String_2" type="string"
nillable="true"/>
+ </sequence>
+ </complexType>
+ <complexType name="echoStringResponse">
+ <sequence>
+ <element name="result" type="string"
nillable="true"/>
+ </sequence>
+ </complexType>
+ <element name="echoSimpleUserType"
type="tns:echoSimpleUserType"/>
+ <element name="echoSimpleUserTypeResponse"
type="tns:echoSimpleUserTypeResponse"/>
+ <element name="echoString" type="tns:echoString"/>
+ <element name="echoStringResponse"
type="tns:echoStringResponse"/>
+ </schema>
+ </types>
+ <message name="JaxRpcTestService_echoSimpleUserType">
+ <part name="parameters" element="ns2:echoSimpleUserType"/>
+ </message>
+ <message name="JaxRpcTestService_echoSimpleUserTypeResponse">
+ <part name="result"
element="ns2:echoSimpleUserTypeResponse"/>
+ </message>
+ <message name="JaxRpcTestService_echoString">
+ <part name="parameters" element="ns2:echoString"/>
+ </message>
+ <message name="JaxRpcTestService_echoStringResponse">
+ <part name="result" element="ns2:echoStringResponse"/>
+ </message>
+ <portType name="JaxRpcTestService"
wsp:PolicyURIs="#RmPolicy">
+ <operation name="echoSimpleUserType">
+ <input message="tns:JaxRpcTestService_echoSimpleUserType"/>
+ <output
message="tns:JaxRpcTestService_echoSimpleUserTypeResponse"/>
+ </operation>
+ <operation name="echoString">
+ <input message="tns:JaxRpcTestService_echoString"/>
+ <output message="tns:JaxRpcTestService_echoStringResponse"/>
+ </operation>
+ </portType>
+ <binding name="JaxRpcTestServiceBinding"
type="tns:JaxRpcTestService">
+ <soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
+ <wsp:PolicyReference URI="#RmPolicy" wsdl:required="true"
/>
+ <wsp:PolicyReference URI="#X509EndpointPolicy"
wsdl:required="true" />
+ <operation name="echoSimpleUserType">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ <operation name="echoString">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="TestService">
+ <wsp:PolicyReference URI="#uselessServicePolicy"
wsdl:required="true" />
+ <port name="JaxRpcTestServicePort"
binding="tns:JaxRpcTestServiceBinding">
+ <wsp:PolicyReference URI="#uselessPortPolicy"
wsdl:required="true" />
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>