0

I'm getting this error:

Two declarations cause a collision in the ObjectFactory class

When running the command to map java classes from a WCF service:

wsimport http://path/to/service.svc?wsdl -Xnocompile -extension -keep -XadditionalHeaders -B-XautoNameResolution

This problem happens because I have two classes with the same name, but in different namespaces (and different properties), like this:

namespace App.TestService.Request
{
    [DataContract]
    public class Foo
    {
     .....

namespace App.TestService.Response
{
    [DataContract]
    public class Foo
    {
     .....

Is there a way to avoid this error without renaming these classes or using (Name="....") attribute?

Beetlejuice
  • 4,292
  • 10
  • 58
  • 84
  • There isn't any clash of class names. The whole point of namespaces is to allow exactly this. I think you have a different problem. – Neil Sep 30 '21 at 12:27
  • Your two namespaces are request and Response and there is no conflict, so there is no conflict between the classes. You can refer to [this post](https://stackoverflow.com/questions/13422253/xjc-two-declarations-cause-a-collision-in-the-objectfactory-class) for error messages – Jiayao Oct 04 '21 at 02:47

0 Answers0