Craig Main

Hi,

Why is the below interface definition not possible

Surely the fact that properties are just methods anyway mean that this should be possible.

Why should it be necessary to change the perfectly reasonable Length property into a GetLength() method

Is there any way to expose a property value

/// <summary>

/// Service contract definition.

/// </summary>

[ServiceContract]

public interface IWorkContract {

[OperationContract]

int Length { get; }

}



Re: Windows Communication Foundation (Indigo) [OperationContract] and properties,

Dennis van.der Stelt

You're sharing class, not schema. Although I've never tried this, I guess you're not allowed to do that! :)



Re: Windows Communication Foundation (Indigo) [OperationContract] and properties,

Craig Main

How am I sharing a class

I am not with you, my contract is an interface, and that interface requires a property in the implementation, the property is remoted. I cannot recall if this sort of thing worked with remoting, but I suspect it did.

Regards

Craig





Re: Windows Communication Foundation (Indigo) [OperationContract] and properties,

Dennis van.der Stelt

It did, because .NET Remoting allows you to share classes.

A property is a part of a class. All it does it provide functionality to change the state of the class so that the behavior changes when calling a method (for example). When all you have is schema, you can't really do this. The way we all should start thinking is that you ask your service if it wants to do something. What you're currently doing is telling the class some info you've already got and then you probably want to ask the outcome. Something like this.

Calculator calc = new Calculator();
calc.x = 2;
calc.y = 10;
calc.MultiplyVaules;
int value = calc.z;

You don't want that. You know everything about the class. But services don't work like that. They might have, but WCF doesn't allow you to do that, because it's SOA based. All you want from your calculator is to multiply the values. So why not like this:

CalculatorClient calc = new CalculatorClient();
int value = calc.MultiplyValues(2, 10);

That's much easier to understand for everyone. If I would've looked at your class, how would I have known that x and y should hold the values to multiply and z would be the return value But the service implementation I've shown you, says it all.





Re: Windows Communication Foundation (Indigo) [OperationContract] and properties,

Craig Main

Hi,

Your statement is made under the assumption that a service contract is always stateless. Although this is typically the case, it does not always have to be the case. I will concede that remote properties are simply not possible. In my opinion they should be, they would provide elegant syntax to session based (stateful) remoting scenarios. Properties are just methods anyway, so why not

I see the point, given the fact that contracts are typically stateless. I do appreciate your example, which makes complete sense. The thing is that it represents only the typical stateless scenario. Why not then also do away with PerSession, and possibly transactions that span more than one method call, since state would be implied in that case.

Regards

Craig





Re: Windows Communication Foundation (Indigo) [OperationContract] and properties,

Dennis van.der Stelt

You're right about sessions, they do exist and you can use them. But I wouldn't compare sessions state to properties.

Transactions aren't there mainly so you can do 5 method calls and all have them inside a transaction. They're also there so you can call a service and everything inside the service enlists to that transaction. So you do something inside your client and want to call a service and wrap all of this inside a transaction.

The funny thing is that you can even let the transaction flow from service1 into serviceA and serviceB, although that is the responsibility of the service you're calling.





Re: Windows Communication Foundation (Indigo) [OperationContract] and properties,

Craig Main

The thing is that is a pretty way of obtaining the state if it is being kept on the server side. It is merely syntactic sugar anyway as a property is a method call without the function call operator appended to the end.

I don't normally have any state on the server side, but using a session for that purpose is instructive and occassionally useful.

Cheers

Craig





Re: Windows Communication Foundation (Indigo) [OperationContract] and properties,

brndnbg

IT WORKS! You have to set the attribute directly before the get- and set-stubs like this:

int Length
{

[OperationContract()] get;
[OperationContract()] set;
}