Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I have an existing class library, with alot of functionallity, I would like to expose these methods/biz objects as a service.

 

I have several command line utilities that use this library as a normal reference, and the .exe and .dll reside in the same directory, but I'd like to be able to expose some of the data access methods as a service so I can access them via ASP.NET, WPF Browser, or Silverlight.

 

[Point being that I'd like to "wrap" the functionallity in the class library in a service so I can update the .dll in the necessary folders and it will not require re-referencing my service or any of the command line apps I've written that already use the .dll version.]

 

Which way will be the best implimentation a WCF Service (can you provide me any resources for getting started with WCF?) or a traditional Asmx Service?

 

TIA

Edited by Nate Bross

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

One issue that I am having specifically is that WCF does not expose my entire object.

 

My business objects, which contain mostly properties, and a few methods for loading those properties are not available on the WCF Client side.

 

Should I create methods in my service for these few "data loading" methods in my business objects?

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

When I mark object with [DataContract] only the private objects are available on the Client Side and NO methods what-so-ever.

 

If I mark with [OperationContract] I get the methods (as expected) but NO Properties.

 

Simplified Class that is giving me trouble:

public Class myClass
{
   String myVal = String.Empty;
   public String MyVal
   { 
       //get/set for myVal
   }
   // no parm constructor
   public myClass() {}
   public myClass(String val)
   {
       myVal = val;
   }

   public Boolean ValidMyVal()
   {
       if(myVal.Length > 5)
           return true;
       else
           return false;
   }
}

 

Problem being that from WCFClient I cannot use the Constructor with parms to set my value, and I cannot access the public properties to set the values myself.

 

I can deal with the [DataContract] only providing access to its private members, but I think it should be exposing it's public properties, and only giving access to private memebrs via (get/set)ers in said properties.

 

TIA

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • Administrators
Posted

that is pretty much how it is designed, classes marked with [DataContract] are really designed as a way of passing information between systems and as such aren't expected to include functionality. [OperationContract] defines server side functionality.

 

If the object existed server side but still exposed all the properties every single property assignment would involve a network trip and also require the server to maintain the state between calls.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • 2 weeks later...
Posted

I found this blog post on WCF:

 

http://jimblogdog.blogspot.com/2008/06/wrap-your-existing-business-layer-with.html

 

I have business objects that contain contain utility methods for easy of use. Methods to take a DataRow, or an XmlNode as input and return a new instance of the business object.

 

I get that the [DataContract] is to represent data, and [serviceContract] is for providing functionallity.

 

Another thing I just realised is that [DataMember] does not support read only properties, any thoughts on addressing this?

 

I would very much like to avoid completely redesigning my business objects and data access layer.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...