[ 
http://issues.apache.org/jira/browse/AXIS-2132?page=comments#action_12316868 ] 

xiao-fei song commented on AXIS-2132:
-------------------------------------

Hi dims,

I have found the reason. It is in org.apache.axis.wsdl.fromJava.Types.java 
where you can see many calls to Document.createElement() like:

            schemaElem = docHolder.createElement("schema");

            wsdlTypesElem.appendChild(schemaElem);
            schemaElem.setAttribute("xmlns", Constants.URI_DEFAULT_SCHEMA_XSD);
            schemaElem.setAttribute("targetNamespace", namespaceURI);

As I checked the java doc:
<java-doc>
createElement

Element createElement(String tagName)
                      throws DOMException

...

Returns:
    A new Element object with the nodeName attribute set to tagName, and 
localName, prefix, and namespaceURI set to null.
</java-doc>

Which means if you create an element using Document.createElement(), call to 
its getLocalName() would return null. That is why we fail to parse the document 
using WSDL4J API. So, my question is, can we call Document.createElementNS() 
instead?

thanks,
xiaofei


> WSDL document object generated by AxisServer can not be read successfully 
> using WSDL4J API
> ------------------------------------------------------------------------------------------
>
>          Key: AXIS-2132
>          URL: http://issues.apache.org/jira/browse/AXIS-2132
>      Project: Apache Axis
>         Type: Bug
>   Components: WSDL processing
>     Versions: 1.2 Beta, 1.2RC1, 1.2RC2, 1.2RC3, 1.2
>  Environment: Testing on windows 2000, tomcat 5.0.28 and 5.5.4, apache axis 
> beta 2 and 1.2 GA
>     Reporter: xiao-fei song
>     Priority: Critical
>  Attachments: QSWSDLHandler.java, UojDocumentService.xml
>
> Our product relies on the feature that AxisServer can return WSDL document 
> which we can process. Basically we do like below:
>             AxisServer engine.generateWSDL(msgContext);
>             Document wsdlDoc = (Document) msgContext.getProperty("WSDL");
> And, the wsdlDoc is the org.w3c.dom.Document type which is what we want.  And 
> we have a simple class which processes the wsdl document like below:
> public class WSDLUtils {
>     private static WSDLReader _wsdlReader = null;
>     public WSDLUtils()
>         throws WSDLException {
>         if (_wsdlReader == null) {
>             WSDLFactory factory = WSDLFactory.newInstance();
>             _wsdlReader = factory.newWSDLReader();
>         }
>     }
>     public WSDLReader getWSDLReader() {
>         return _wsdlReader;
>     }
>     public Definition getWSDLDefinition(Document wsdlDoc)
>         throws WSDLException {
>         WSDLReader reader = getWSDLReader();
>         return reader.readWSDL(null, wsdlDoc);
>     }
> }
> And everytime we run this, we get the exception like this:
> July21 11:42:45 2005: [Thread-18] java.lang.IllegalArgumentException: local 
> part cannot be "null" when creating a QName
> July21 11:42:45 2005: [Thread-18]     at 
> javax.xml.namespace.QName.<init>(QName.java:123)
> July21 11:42:45 2005: [Thread-18]     at 
> javax.xml.namespace.QName.<init>(QName.java:89)
> July21 11:42:45 2005: [Thread-18]     at 
> com.ibm.wsdl.util.xml.QNameUtils.newQName(Unknown Source)
> July21 11:42:45 2005: [Thread-18]     at 
> com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source)
> July21 11:42:45 2005: [Thread-18]     at 
> com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
> July21 11:42:45 2005: [Thread-18]     at 
> com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
> July21 11:42:45 2005: [Thread-18]     at 
> com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
> July21 11:42:45 2005: [Thread-18]     at 
> com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
> July21 11:42:45 2005: [Thread-18]     at 
> org.apache.axis.transport.http.QSWSDLHandler.invoke(QSWSDLHandler.java:83)
> July21 11:42:45 2005: [Thread-18]     at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> July21 11:42:45 2005: [Thread-18]     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> July21 11:42:45 2005: [Thread-18]     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> July21 11:42:45 2005: [Thread-18]     at 
> java.lang.reflect.Method.invoke(Method.java:324)
> July21 11:42:45 2005: [Thread-18]     at 
> org.apache.axis.transport.http.AxisServlet.processQuery(AxisServlet.java:1310)
> July21 11:42:45 2005: [Thread-18]     at 
> org.apache.axis.transport.http.AxisServlet.doGet(AxisServlet.java:261)
> July21 11:42:45 2005: [Thread-18]     at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> July21 11:42:45 2005: [Thread-18]     at 
> org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:373)
> July21 11:42:45 2005: [Thread-18]     at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> So I decided to test on axis itself and after modified 
> org.apache.axis.transport.http.QSWSDLHandler#invoke() method add lines like 
> below (line 74)
>             try {
>                 //beginning of test
>                 WSDLFactory wsdlFactory = WSDLFactory.newInstance();
>                 WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
>                 wsdlReader.setFeature("javax.wsdl.verbose", true);
>                 Definition definition = wsdlReader.readWSDL(null, wsdlDoc);
>                 System.out.println("definition = " + definition);
>                 //end of test
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
> And compile axis and test 
> http://localhost:8080/axis/services/AdminService?wsdl to invoke the method 
> above, and I saw exactly the same exception in the console, which means that 
> the wsdl document object returned by AxisServer.generateWSDL() can not be 
> processed by WSDL4J API.
> Couple of others:
> 1. the tests failed in 1.2 beta2 and 1.2GA, so it should not be a problem of 
> WSDL4J
> 2. http://localhost:8080/axis/services/Version?wsdl works okay in beta and GA
> 3. I wrote test case like below:
>     public static Definition testA() {
>         Definition definition = null;
>         try {
>             String filename = "d:/dl/UojDocumentService.xml";
>             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>             /*note*/ dbf.setNamespaceAware(true);
>             DocumentBuilder db = dbf.newDocumentBuilder();
>             FileInputStream fis = new FileInputStream(new File(filename));
>             InputSource inp = new InputSource(fis);
>             
>             Document doc = db.parse(inp);
>             System.out.println("doc = " + doc);
>             
>             WSDLFactory wsdlFactory = WSDLFactory.newInstance();
>             WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
>             definition = wsdlReader.readWSDL(null, doc);
>             System.out.println("definition = " + definition);
>             
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>         return definition;
>     }
> After saving the wsdl as the xml file on disk, the code above runs okay. But 
> if I didn't run /*note*/ dbf.setNamespaceAware(true); I get similar exception 
> as above.
> 3. running WSDL4J process the wsdl online runs okay so the problem has to be 
> in the docuemnt object rather than the xml document.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to