0

I'm developing an aplication in java (JSF) which communicates whith an WCF web server. I developed the webserver using c#, and I'm havin trouble to send the equals implementation of an complex object to the java client. For example, consider this c# class:

[DataContract(Namespace = "http://mywebservice.com/Entidades")]
    public class Record{private Int64 id;
    [DataMember]
    public Int64 Id
    {
        get { return id; }
        set { id = value; }
    }

    public override bool Equals(Object obj)
    {
          if(obj is Record){
               Record rec = obj as Record;
               return rec.Id == this.Id;
         }
         return false;
    }

}

First tryed to put the [DataMember] in the equals, but I discovered that I can't do that. How is the right way to send this implementation of the "equals" of this complex type to the java client?

Thanks in advance

PauloRLA
  • 3
  • 1
  • What would you expect the XML to look like? – SLaks May 08 '12 at 15:34
  • I was hoping that it was possible to send the equals overload over the xml with the complex types definitions. Something like: ...Definitions... – PauloRLA May 09 '12 at 11:41

2 Answers2

4

That doesn't make sense.
Web services transfer data, not code.

You need to implement equals() in you Java objects in source.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

Equals is a method, not a property. As such, I don't know of any way you can simply expose this functionality in the model your service exposes.

MattN
  • 198
  • 8
  • Could expose an operation that takes in two records and returns a bool, but that seems like overkill. – zimdanen May 08 '12 at 15:37
  • If the equals method contains a significant amount of business logic, then you could justify adding it as a service method/operation. Either way, the service operations are not part of the model. – MattN May 08 '12 at 18:24
  • There is significant business logic in the method equals, but I need to reduce as much as I can the traffic between the webserver and the client. I was thinking in send the equals with the complexType definition to reduce the overhead, instead of creating a webserver method. But with a second thought, analyzing yours answers, this really doesn't makes sense – PauloRLA May 08 '12 at 20:21