File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes XmlException on calling WSDL2Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "XmlException on calling WSDL2Java " Watch "XmlException on calling WSDL2Java " New topic
Author

XmlException on calling WSDL2Java

Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 237
Hi All,
I'm currently getting the following error, on calling the following within my antscript:-
<java className="org.apache.axis2.wsdl.WSDL2Java" classpathref="${axis2classpath}">

Error:
[java] org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

[java] Caused by: java.lang.RuntimeException: org.apache.xmlbeans.XmlException: error: cos-nonambig: Content model violates the unique particle attribution rule.

[java] Caused by: org.apache.xmlbeans.XmlException: error: cos-nonambig: Content model violates the unique particle attribution rule.

Has anybody seen this one before?.

Mat
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi. Did you resolve the issue? Here are a couple of links with an explanation of the Unique Particle Attribution rule and some examples:

- Section 7.4.1.3 here: http://docstore.mik.ua/orelly/xml/schema/ch07_04.htm
- http://technet.microsoft.com/en-us/library/ms187822.aspx

If you can narrow down your wsdl types section, then it might be easier to find. Or come to think of it ... I remember that in Eclipse, you should be able to ask it to validate your schemas, and it will get you close to the location of the problem. If you still can't find it, please attach your wsdl and I can take a look. Hope that helps.
Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 237
Hi Srini,
I could not resolve this problem, so I have included the wsdl.
I used to be able to generate my skeleton & stubs via the command WSDL2jAVA (using antscript) without getting the above error.
I was using AXIS2 and jdk1.4 with my antscript. I have now changed to jdk1.5 and this seems to be
generating different schemas xmlns at the top of the wdsl file. The interface class that I use to generate
the wsdl using the command JAVA2WSDL (using antscript) has not changed. I have no idea how to solve this one

R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi Mat. So this is what I had to do. In Eclipse, I did File-->New-->Other, then selected WSDL to create a new WSDL file, and then pasted your wsdl in there. You can then right-click the WSDL and select Validate from the context menu to validate it. Here are the changes I needed to make to fix it:

Change 1
Error: The processing instruction target matching "[xX][mM][lL]" is not allowed.
Resolution: Removed 1st line <?xml ...>

Change 2
cvc-identity-constraint.4.2.2: Duplicate key value [PersonPVOSecure] declared for identity constraint "type" of element "schema".

Comments: The third xs:schema in namespace ax24 has two definitions for PersonPVOSecure. Can't have more than one. So name one of them something else. In this case, I named the second one PersonPVOSecure002. You will have to rename and modify any references to it.

The revised wsdl is below. If you don't want multiple schemas in the wsdl:types section, then you will have to manually merge them.
Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 237
Hi Srini,
thank you for your response, it was very helpfull .
The extra complexType name="PersonPVOSecure" within <xs:schema xmlns:ax24
Could that have been generated because during the wsdl2java it could have possibly picked up two
different PersonPVOSecure on the class path

In my original wsdl I had the following at top of the auto generated wsdl and I was still able to develop ws


I currently use contract last to generate my ws using Axis2, but after this experience, I think I will stop being lazy and start to use the contract first approach.

Mat
Mat Anthony
Ranch Hand

Joined: May 21, 2008
Posts: 237
Hi Srini,
sorry on my previous message i should have said:-
Could that have been generated because during the java2wsdl it could have possibly picked up two
different PersonPVOSecure on the class path.

I have also noticed that the name spaces used have changed, could this because I have switched to jdk 1.5 from jdk 1.4

Mat
R Srini
Ranch Hand

Joined: Feb 19, 2010
Posts: 215
Hi Mat. Yes, Contract-first is considered a best practice. Its the same as interface-based programming - the interface is the contract.

- Regarding the <?xml> processing instruction, it is because it needs to be the very first line in an xml document, but its the second line in your first post. I didn't notice that yesterday. Probably a copy/paste error. So we can ignore this one.
- But I have no idea why it might generate duplicate types. There are bugs that look similar. Could be a wsdl2java issue where it generates code instead of reporting an error. Don't know. If you are using an older version of Axis, then you could try a newer version, maybe 1.4 or 1.5.
- As far as the namespaces changing, I have no idea.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XmlException on calling WSDL2Java