Skip to main content

Name conflicts when consuming a web service

2 replies [Last post]
gusgorman
Offline
Joined: 2012-06-28
Points: 0

Hi,

Apologies if this shows up as a double post. My previous thread gives a "page not found" error when I try to view it.

I am trying to comsume a web service. If I do not specify a target package, then everything is ok:

$ wsimport.exe -s src/ -d bin/ http://localhost/QMIS/QmisPaperService.svc?wsdl
parsing WSDL...
generating code...
compiling code...

However, If I specify a target package:

$ wsimport.exe -s src/ -d bin/ -p org.bcs.qmis http://localhost/QMIS/QmisPaperService.svc?wsdl
parsing WSDL...

[ERROR] A class/interface with the same name "org.bcs.qmis.ValidateExamPaperNoResponse" is already in use. Use a class customization to resolve this conflict.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd0

[ERROR] (Relevant to above error) another "ValidateExamPaperNoResponse" is generated from here.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd3

[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd3

[ERROR] (Related to above error) This is the other declaration.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd0

[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd2

[ERROR] (Related to above error) This is the other declaration.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd0

If I then add the -B-XautoNameResolution switch:

$ wsimport.exe -s src/ -d bin/ -p org.bcs.qmis -B-XautoNameResolution http://localhost/QMIS/QmisPaperService.svc?wsdl
parsing WSDL...

[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd2

[ERROR] (Related to above error) This is the other declaration.
line 1 of http://localhost/QMIS/QmisPaperService.svc?xsd=xsd0

I am guessing this is because the original service (which happens to have been developed in .NET) has method signatures such as:
ValidateExamPaperNoResponse ValidateExamPaperNo(ValidateExamPaperNoRequest request); and wsimport generates classes such as "ValidateExamPaperNoResponse" and "ValidateExamPaperNoRequest" for its own internal use. Is there any way round this problem?

regards,
Jordan.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jungicz
Offline
Joined: 2004-08-17
Points: 0

Hi,

The solution for this type of issue is to use the customization, see Class Customization section in http://jax-ws.java.net/nonav/2.2.7/docs/ch03.html#standard-customizations for details or samples[1].

HTH,
--lukas

[1]: https://svn.java.net/svn/jax-ws~sources/branches/jaxws22/jaxws-ri/sample...

gusgorman
Offline
Joined: 2012-06-28
Points: 0

Cool, thanks for the tip!
Jordan.