bulldog2011/nano

Issue with namespace when generated *.java file from wsdl

4everalone opened this issue · 3 comments

Hi, there is a compilation error after generation java code. I'm generating the code from wsdl during compilation of my project, so manual fixing is not unacceptably for me.

Here is an quick example of generated code. Compilation error is on the line

public List<Element> any;

Because Element is a class from org.w3c.dom namespace

// Generated by xsd compiler for android/java
// DO NOT CHANGE!
package ws.schema;

import java.io.Serializable;
import com.leansoft.nano.annotation.*;
import java.util.List;
import org.w3c.dom.Element;

@RootElement(name = "RequestData", namespace = "ws/schema")
public class RequestData implements Serializable {

   private static final long serialVersionUID = -1L;

    @Element(name = "LoginInfo")
    @Order(value=0)
    public LoginInfo loginInfo;

    @AnyElement
    @Order(value=1)
    public List<Element> any;   
}

Hi,

Nano depends on XML DOM parser which is included in both Android JDK and standard Oracle/Sun JDK.

Are you compiling the generated code with these standard JDKs? and what is the error message produced by the compiler?

Thx!
-William

Thank you for reply.

Error message is: "Type mismatch: cannot convert from Element to Annotation"
Eclipse highlighting this line

@Element(name = "LoginInfo")

I'm compiling with standard JDKs, I mean your annotation @element conflicts with imported class "org.w3c.dom.Element;"

I was looking at your code and seems I reported an issue in incorrect project, i'm sorry.
Template for class generation is placed here https://github.com/bulldog2011/mxjc
I would expect to see:

@com.leansoft.nano.annotation.Element(name = "LoginInfo")

because of name conflict with "import org.w3c.dom.Element;"

Can you please advise a different solution instead of changing your sources?

Hi,

Usually, the any element in schema will be mapped to java.lang.Object, are you using processContents='skip' with any element in your schema defintion? if this is the case, then any element will be mapped to org.w3c.dom.Element, can you check your schema and try to change accordingly?
here is the jaxb any element mapping details:
https://jaxb.java.net/guide/Mapping_of__xs_any___.html

Anyway, this is a bug of the binding framework, I have logged the issue, will spend some effort to fix it later.