Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Store Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems.

Go Back   Vista Forums > Vista technology newsgroups > Indigo

behavior attribute for client proxy: WITHOUT ANY CODING???

Reply
 
Thread Tools Display Modes
Old 02-06-2008   #1 (permalink)
belochka
Guest
 
Posts: n/a

behavior attribute for client proxy: WITHOUT ANY CODING???

Hi guys,

We have a WCF service accepting requests with custom context object in SOAP
header coming from the client. For this purpose we did the following:

1) On Server Side - applied custom attribute to contract interface (or
service behavior attribute to service class).

2) On Client Side - we ether use app.config to apply custom endpoint
behavior or physically edit generated proxy file and apply custom contract
attribute to proxy interface.

I.e. everything is as MSDN says.

Now, the question is: Is it possible to make client apply the custom
behavior AUTOMATICALLY without any physical app.config modification or
physical coding in generated proxy file? It would be really nice to just
"consume" the service with standard VS2008 "add service reference"
functionality and it would support my custom header object insertion
automatically, without any need of client coding.

I guess there should be something custom in service generated wsdl that
would tell my client to add extra attribute to generated proxy contract
interface ...

I.e. instead of having the following in generated proxy reference:

------ Code Snippet ------
[GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[ServiceContractAttribute(ConfigurationName="PaymentServiceReference.PaymentService")]
public interface IPaymentService
{
// method prototypes ...
}
-----------------------------

I want to have something like:

------ Code Snippet ------
[GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[ServiceContractAttribute(ConfigurationName="PaymentServiceReference.PaymentService")]
[InsertCustomContextContractBehaviorAttribute] // <--- this one is required
!!!
public interface IPaymentService
{
// method prototypes ...
}
-----------------------------

with extra attribute.

Does anyone know how i can achieve this? May be there is a way to
automatically generate something in app.config instead of applying custom
attribute?

Thanks,
Belochka.


  Reply With Quote

Old 02-07-2008   #2 (permalink)
blackbelt
Guest
 
Posts: n/a

RE: behavior attribute for client proxy: WITHOUT ANY CODING???

Yes, there is. Look add the behavior in

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior>
<customBehavior />
</behavior>
</endpointBehaviors>
</behaviors>
<extensions>
<add name="customBehavior" type="..." />
</extensions>
</system.serviceModel>

You will need a class that inherits from BehaviorExtensionElement and that
is the type registered in the extensions element...

Hope this helps,

Carlos

"belochka" wrote:
Quote:

> Hi guys,
>
> We have a WCF service accepting requests with custom context object in SOAP
> header coming from the client. For this purpose we did the following:
>
> 1) On Server Side - applied custom attribute to contract interface (or
> service behavior attribute to service class).
>
> 2) On Client Side - we ether use app.config to apply custom endpoint
> behavior or physically edit generated proxy file and apply custom contract
> attribute to proxy interface.
>
> I.e. everything is as MSDN says.
>
> Now, the question is: Is it possible to make client apply the custom
> behavior AUTOMATICALLY without any physical app.config modification or
> physical coding in generated proxy file? It would be really nice to just
> "consume" the service with standard VS2008 "add service reference"
> functionality and it would support my custom header object insertion
> automatically, without any need of client coding.
>
> I guess there should be something custom in service generated wsdl that
> would tell my client to add extra attribute to generated proxy contract
> interface ...
>
> I.e. instead of having the following in generated proxy reference:
>
> ------ Code Snippet ------
> [GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
> [ServiceContractAttribute(ConfigurationName="PaymentServiceReference.PaymentService")]
> public interface IPaymentService
> {
> // method prototypes ...
> }
> -----------------------------
>
> I want to have something like:
>
> ------ Code Snippet ------
> [GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
> [ServiceContractAttribute(ConfigurationName="PaymentServiceReference.PaymentService")]
> [InsertCustomContextContractBehaviorAttribute] // <--- this one is required
> !!!
> public interface IPaymentService
> {
> // method prototypes ...
> }
> -----------------------------
>
> with extra attribute.
>
> Does anyone know how i can achieve this? May be there is a way to
> automatically generate something in app.config instead of applying custom
> attribute?
>
> Thanks,
> Belochka.
>
>
  Reply With Quote
Old 02-08-2008   #3 (permalink)
belochka
Guest
 
Posts: n/a

RE: behavior attribute for client proxy: WITHOUT ANY CODING???

Well, this is not really what i meant

The problem is not to configure server side to use the custom behavior.

What i want is that SERVER behavior config (or attribute) would be somehow
picked up by the CLIENT during client proxy class generation. So, i dont want
to write any code or modify config on CLIENT side. I want to implement custom
behavior on the WCF service class or interface (using attribute), then on
client side "add server reference" in VS2008 and it should be smart enough to
somehow recognize custom attribute for my WCF service class or interface and
apply THE SAME attribute to the client proxy AUTOMATICALLY (as long as i
reference the same dll on the client, of course).

One of the suggestions I got from MSFT guys on MSDN forum is to customize
WSDL generation/consumption using IWsdlImporter. If there is no better
choice, i'll have to try doing it this way.

"blackbelt" wrote:
Quote:

> Yes, there is. Look add the behavior in
>
> <system.serviceModel>
> <behaviors>
> <endpointBehaviors>
> <behavior>
> <customBehavior />
> </behavior>
> </endpointBehaviors>
> </behaviors>
> <extensions>
> <add name="customBehavior" type="..." />
> </extensions>
> </system.serviceModel>
>
> You will need a class that inherits from BehaviorExtensionElement and that
> is the type registered in the extensions element...
>
> Hope this helps,
>
> Carlos
>
> "belochka" wrote:
>
Quote:

> > Hi guys,
> >
> > We have a WCF service accepting requests with custom context object in SOAP
> > header coming from the client. For this purpose we did the following:
> >
> > 1) On Server Side - applied custom attribute to contract interface (or
> > service behavior attribute to service class).
> >
> > 2) On Client Side - we ether use app.config to apply custom endpoint
> > behavior or physically edit generated proxy file and apply custom contract
> > attribute to proxy interface.
> >
> > I.e. everything is as MSDN says.
> >
> > Now, the question is: Is it possible to make client apply the custom
> > behavior AUTOMATICALLY without any physical app.config modification or
> > physical coding in generated proxy file? It would be really nice to just
> > "consume" the service with standard VS2008 "add service reference"
> > functionality and it would support my custom header object insertion
> > automatically, without any need of client coding.
> >
> > I guess there should be something custom in service generated wsdl that
> > would tell my client to add extra attribute to generated proxy contract
> > interface ...
> >
> > I.e. instead of having the following in generated proxy reference:
> >
> > ------ Code Snippet ------
> > [GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
> > [ServiceContractAttribute(ConfigurationName="PaymentServiceReference.PaymentService")]
> > public interface IPaymentService
> > {
> > // method prototypes ...
> > }
> > -----------------------------
> >
> > I want to have something like:
> >
> > ------ Code Snippet ------
> > [GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
> > [ServiceContractAttribute(ConfigurationName="PaymentServiceReference.PaymentService")]
> > [InsertCustomContextContractBehaviorAttribute] // <--- this one is required
> > !!!
> > public interface IPaymentService
> > {
> > // method prototypes ...
> > }
> > -----------------------------
> >
> > with extra attribute.
> >
> > Does anyone know how i can achieve this? May be there is a way to
> > automatically generate something in app.config instead of applying custom
> > attribute?
> >
> > Thanks,
> > Belochka.
> >
> >
  Reply With Quote
 
Reply

Thread Tools
Display Modes









Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48