Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with namespace when generated *.java file from wsdl #2

Open
4everalone opened this issue Jun 7, 2013 · 3 comments
Open

Issue with namespace when generated *.java file from wsdl #2

4everalone opened this issue Jun 7, 2013 · 3 comments

Comments

@4everalone
Copy link

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;   
}
@bulldog2011
Copy link
Owner

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

@4everalone
Copy link
Author

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?

@bulldog2011
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants