Author: alessio.soldano(a)jboss.com
Date: 2009-01-15 10:11:11 -0500 (Thu, 15 Jan 2009)
New Revision: 9049
Added:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/resources/common/wsdl11/PolicyAttachmentAndUnknownExtElem.wsdl
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
Log:
[JBWS-2449] Parsing not understood extensibility elements
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java 2009-01-15
13:44:26 UTC (rev 9048)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java 2009-01-15
15:11:11 UTC (rev 9049)
@@ -44,6 +44,7 @@
private Map features = new LinkedHashMap();
private Map properties = new LinkedHashMap();
private Map<String,List<WSDLExtensibilityElement>> extElements = new
LinkedHashMap<String,List<WSDLExtensibilityElement>>();
+ private List<WSDLExtensibilityElement> notUnderstoodExtElement = new
LinkedList<WSDLExtensibilityElement>();
public WSDLFeature[] getFeatures()
{
@@ -113,4 +114,19 @@
}
return list;
}
+
+ public List<WSDLExtensibilityElement> getNotUnderstoodExtElement()
+ {
+ return notUnderstoodExtElement;
+ }
+
+ public void setNotUnderstoodExtElement(List<WSDLExtensibilityElement>
notUnderstoodExtElement)
+ {
+ this.notUnderstoodExtElement = notUnderstoodExtElement;
+ }
+
+ public void addNotUnderstoodExtElement(WSDLExtensibilityElement element)
+ {
+ notUnderstoodExtElement.add(element);
+ }
}
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2009-01-15
13:44:26 UTC (rev 9048)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/tools/wsdl/WSDL11Reader.java 2009-01-15
15:11:11 UTC (rev 9049)
@@ -313,33 +313,78 @@
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
+ if (extElement instanceof UnknownExtensibilityElement)
+ {
+ UnknownExtensibilityElement uee = (UnknownExtensibilityElement)extElement;
+ boolean understood = false;
+ understood = understood || processPolicyElements(uee, dest);
+ understood = understood || processUseAddressing(uee, dest);
+ //add processing of further extensibility element types below
+
+ if (!understood)
+ {
+ processNotUnderstoodExtesibilityElement(uee, dest);
+ }
+ }
}
}
- private void processPolicyElements(ExtensibilityElement extElement, Extendable dest)
+ /**
+ * Process the provided extensibility element looking for policies or policy
references.
+ * Returns true if the provided element is policy related, false otherwise.
+ *
+ * @param extElement
+ * @param dest
+ * @return
+ */
+ private boolean processPolicyElements(UnknownExtensibilityElement extElement,
Extendable dest)
{
- if (extElement instanceof UnknownExtensibilityElement)
+ boolean result = false;
+ Element srcElement = extElement.getElement();
+ if (Constants.URI_WS_POLICY.equals(srcElement.getNamespaceURI()))
{
- Element srcElement = ((UnknownExtensibilityElement)extElement).getElement();
- if (Constants.URI_WS_POLICY.equals(srcElement.getNamespaceURI()))
+ //copy missing namespaces from the source element to our element
+ Element element = (Element)srcElement.cloneNode(true);
+ copyMissingNamespaceDeclarations(element, srcElement);
+ if (element.getLocalName().equals("Policy"))
{
- //copy missing namespaces from the source element to our element
- Element element = (Element)srcElement.cloneNode(true);
- copyMissingNamespaceDeclarations(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));
- }
-
+ WSDLExtensibilityElement el = new
WSDLExtensibilityElement(Constants.WSDL_ELEMENT_POLICY, element);
+
el.setRequired("true".equalsIgnoreCase(element.getAttribute("required")));
+ dest.addExtensibilityElement(el);
+ result = true;
}
+ else if (element.getLocalName().equals("PolicyReference"))
+ {
+ WSDLExtensibilityElement el = new
WSDLExtensibilityElement(Constants.WSDL_ELEMENT_POLICYREFERENCE, element);
+
el.setRequired("true".equalsIgnoreCase(element.getAttribute("required")));
+ dest.addExtensibilityElement(el);
+ result = true;
+ }
}
+ return result;
}
+
+ /**
+ * Process the provided extensibility element looking for UsingAddressing.
+ * Returns true if the provided element is UsingAddressing, false otherwise.
+ *
+ * @param extElement
+ * @param dest
+ * @return
+ */
+ private boolean processUseAddressing(UnknownExtensibilityElement extElement,
Extendable dest)
+ {
+ log.warn("UsingAddressing extensibility element not supported yet.");
+ return false;
+ }
+
+ private void processNotUnderstoodExtesibilityElement(UnknownExtensibilityElement
extElement, Extendable dest)
+ {
+ Element element = (Element)extElement.getElement().cloneNode(true);
+ WSDLExtensibilityElement notUnderstoodElement = new
WSDLExtensibilityElement("notUnderstoodExtensibilityElement", element);
+
notUnderstoodElement.setRequired("true".equalsIgnoreCase(element.getAttributeNS(Constants.NS_WSDL11,
"required")));
+ dest.addNotUnderstoodExtElement(notUnderstoodElement);
+ }
private void processTypes(Definition srcWsdl, URL wsdlLoc) throws IOException,
WSDLException
{
Added:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java
===================================================================
---
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java
(rev 0)
+++
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java 2009-01-15
15:11:11 UTC (rev 9049)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.common.wsdl11;
+
+import java.io.File;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.ws.Constants;
+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.WSDLService;
+import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
+import org.jboss.wsf.test.JBossWSTest;
+import org.w3c.dom.Element;
+
+/**
+ * Test the unmarshalling of wsdl-1.1 into the unified wsdl structure
+ * using known and unknown wsdl extensibility elements.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 15-Jan-2009
+ */
+public class WSDLExtensElemTestCase extends JBossWSTest
+{
+ public void testPolicyEndpointExtensibilityElements() throws Exception
+ {
+ File wsdlFile = getResourceFile("common/wsdl11/PolicyAttachment.wsdl");
+ assertTrue(wsdlFile.exists());
+
+ 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");
+ List<WSDLExtensibilityElement> portNotUnderstoodList =
wsdlEndpoint.getNotUnderstoodExtElement();
+ assertNotNull(portNotUnderstoodList);
+ assertEquals(0, portNotUnderstoodList.size());
+
+ 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");
+ List<WSDLExtensibilityElement> bindingNotUnderstoodList =
wsdlBinding.getNotUnderstoodExtElement();
+ assertNotNull(bindingNotUnderstoodList);
+ assertEquals(0, bindingNotUnderstoodList.size());
+ }
+
+ public void testPolicyAndUnkwnownEndpointExtensibilityElements() throws Exception
+ {
+ File wsdlFile =
getResourceFile("common/wsdl11/PolicyAttachmentAndUnknownExtElem.wsdl");
+ assertTrue(wsdlFile.exists());
+
+ 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");
+ List<WSDLExtensibilityElement> portNotUnderstoodList =
wsdlEndpoint.getNotUnderstoodExtElement();
+ assertNotNull(portNotUnderstoodList);
+ assertEquals(1, portNotUnderstoodList.size());
+ assertUnknownExtElem(portNotUnderstoodList.get(0), "foo1",
"http://foo.org/foo1", "bar", true);
+
+ 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");
+ List<WSDLExtensibilityElement> bindingNotUnderstoodList =
wsdlBinding.getNotUnderstoodExtElement();
+ assertNotNull(bindingNotUnderstoodList);
+ assertEquals(2, bindingNotUnderstoodList.size());
+ assertUnknownExtElem(bindingNotUnderstoodList.get(0), "foo1",
"http://foo.org/foo1", "bar", false);
+ assertUnknownExtElem(bindingNotUnderstoodList.get(1), "foo2",
"http://foo.org/foo2", "bar", false);
+ }
+
+ private static 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...);
+
assertEquals(el.getAttributeNode("URI").getValue(),"#"+policyURI);
+ }
+
+ private static void assertUnknownExtElem(WSDLExtensibilityElement extEl, String
prefix, String namespaceURI, String localName, boolean required)
+ {
+ Element el = extEl.getElement();
+ QName qName = new QName(el.getNamespaceURI(),el.getLocalName(),el.getPrefix());
+ assertEquals(qName, new QName(namespaceURI, localName, prefix));
+ assertEquals(required,
"true".equals(el.getAttributeNS(Constants.NS_WSDL11, "required")));
+ }
+}
Property changes on:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/resources/common/wsdl11/PolicyAttachmentAndUnknownExtElem.wsdl
===================================================================
---
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/resources/common/wsdl11/PolicyAttachmentAndUnknownExtElem.wsdl
(rev 0)
+++
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/resources/common/wsdl11/PolicyAttachmentAndUnknownExtElem.wsdl 2009-01-15
15:11:11 UTC (rev 9049)
@@ -0,0 +1,139 @@
+<?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:foo1="http://foo.org/foo1"
+
xmlns:foo2="http://foo.org/foo2"
+
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" />
+ <foo1:bar wsdl:required="false"/>
+ <foo2:bar/>
+ <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" />
+ <foo1:bar wsdl:required="true"/>
+ <soap:address location="REPLACE_WITH_ACTUAL_URL"/>
+ </port>
+ </service>
+</definitions>
Property changes on:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/resources/common/wsdl11/PolicyAttachmentAndUnknownExtElem.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF