You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by di...@apache.org on 2009/08/21 15:27:22 UTC

svn commit: r806543 - /webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/PrefixCollector.java

Author: dims
Date: Fri Aug 21 13:27:22 2009
New Revision: 806543

URL: http://svn.apache.org/viewvc?rev=806543&view=rev
Log:
Fix for the following stack trace:

                                 java.lang.IllegalStateException: The prefix xs is not bound.
	at org.apache.ws.commons.schema.SchemaBuilder.getRefQName(SchemaBuilder.java:671)
	at org.apache.ws.commons.schema.SchemaBuilder.getRefQName(SchemaBuilder.java:644)
	at org.apache.ws.commons.schema.SchemaBuilder.handleElement(SchemaBuilder.java:1487)
	at org.apache.ws.commons.schema.SchemaBuilder.handleSequence(SchemaBuilder.java:1045)
	at org.apache.ws.commons.schema.SchemaBuilder.handleComplexType(SchemaBuilder.java:739)
	at org.apache.ws.commons.schema.SchemaBuilder.handleElement(SchemaBuilder.java:1514)
	at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:291)
	at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:412)
	at org.apache.axis2.description.WSDLToAxisServiceBuilder.getXMLSchema(WSDLToAxisServiceBuilder.java:144)
	at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.copyExtensibleElements(WSDL11ToAxisServiceBuilder.java:2317)
	at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.processTypes(WSDL11ToAxisServiceBuilder.java:413)
	at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.processTypes(WSDL11ToAxisServiceBuilder.java:430)
	at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.processTypes(WSDL11ToAxisServiceBuilder.java:402)
	at org.apache.axis2.description.WSDL11ToAxisServiceBuilder.populateService(WSDL11ToAxisServiceBuilder.java:346)
	at org.apache.axis2.jaxws.description.impl.EndpointDescriptionImpl.buildAxisServiceFromWSDL(EndpointDescription

In Axis2's WSDL11ToAxisBuilder.java, there is code that converts from multiple message parts like so

    <wsdl:message name="testMultipleSwAResponseMsg">
        <wsdl:part name="testOutputSwA" type="bons1:TestBO"/>
        <wsdl:part name="swaOutput1" type="xsd:hexBinary"/>
        <wsdl:part name="swaOutput2" type="xsd:hexBinary"/>
        <wsdl:part name="swaOutput3" type="xsd:base64Binary"/>
    </wsdl:message>

into XML Schema based ComplexType(s). Basically a new ComplexType is created with a XMLSchema sequence inside
which you would see all the 4 parts. During this processing there is a code path where we lose fact that xsd 
prefix is mapped to xml schema namespace and it ends up using a xs as the prefix instead of xsd and the 
subsequent issue with xs prefix not found. This happens bec ause the complex type is created in the top level 
wsdl which has no declaration for xmlns:xsd or xmlns:xs 



Modified:
    webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/PrefixCollector.java

Modified: webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/PrefixCollector.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/PrefixCollector.java?rev=806543&r1=806542&r2=806543&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/PrefixCollector.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/utils/PrefixCollector.java Fri Aug 21 13:27:22 2009
@@ -39,9 +39,10 @@
      * declarations are ignored.
      */
     public void searchLocalPrefixDeclarations(Node pNode) {
-        if (pNode.getNodeType() == Node.ELEMENT_NODE) {
+        short type = pNode.getNodeType();
+        if (type == Node.ELEMENT_NODE || type == Node.DOCUMENT_NODE) {
             NamedNodeMap map = pNode.getAttributes();
-            for (int i = 0; i < map.getLength(); i++) {
+            for (int i = 0; map != null && i < map.getLength(); i++) {
                 Node attr = map.item(i);
                 final String uri = attr.getNamespaceURI();
                 if (Constants.XMLNS_ATTRIBUTE_NS_URI.equals(uri)) {