tags:

views:

262

answers:

3

Basically, I have a server-side type "Foo" with members X and Y. Whenever I use Visual Studio's "Add Server Reference" then I see the WSDL and the generated proxy both append the word "Field" to all the members and change the casing of the first letter. IE, "X" and "Y" are renamed "xField" and "yField". Any idea why this is happening? I can't figure out the pattern.

Details -- I have a legacy ASMX web service which exposes a "Foo" type. I created a new WCF service that's a wrapper around that old web service -- the new service just wraps those methods and maybe updates the values of a few fields, but it exposes the exact same methods and returns the exact same types. I've tried re-creating the referenes several times, and every time, it always renames my fields: the varible "STUFF" is exposed in the wsdl and proxy as "sTUFFField". Variable "X" is exposed as "xField", etc.

Funny thing is I can't figure out the pattern -- I tried creating a new ASMX web service as a test and wrapping that -- variables are not renamed then. So I can't figure out the pattern of why/when WCF renames variables.

Anybody know?

+2  A: 

Typically, the generated proxy will have "XField" and "YField" as internal/protected/private fields, and expose the values through properties called "X" and "Y". There are options you can set when creating the proxy client to tweak that to your liking, I think.

UPDATE: I don't seem to find any switches or options to control this behavior. It might depend on which serializer (DataContractSerializer vs. XmlSerializer) WCF uses for creating the client proxy.

In the end, it's really more or less just an issue of coding style - functionally, it shouldn't make a difference.

Marc

marc_s
Right, that's how it NORMALY works, but I'm seeing the public fields are renamed to. So the internal fields are called "XFieldField" and the public accessor is called "XField". Not what I want, and it means the interface to the wrapper service becomes different than the interface to the actual service. So I can no longer treat the two services interchangably.
tavistmorph
THat's odd and unexpected - how do you create your client proxy? In Visual Studio or using svcutil.exe ??
marc_s
Exactly -- odd and unexpected. It's only happening on this one project, so I can't figure out the pattern. But I created the client proxy with Visual Studio, just by clicking "Add service reference".
tavistmorph
A: 

@tavistmorph -- Were you able to find a solution? I'm experiencing the same problem.

I'm accessing a web service through two application tiers (WCF calls). Its something like this

  • Java web service -> Service Foo -> Property UserId
  • WCF Internal -> Reference FooProxy -> Property UserId
  • WCF External -> Reference FooIntProxy -> property userIdField
  • Web Appln -> Reference FooExtProxy -> Propety userIdFieldField

Is there a switch to prevent this 'Field' from getting appended to the generated members?

OrbitZen
A: 

I had the same problem but i was able to find solution.

In the interface if you add [DataContractFormat] tag you will end up with "XFieldField" case. But if you replace it with [XmlSerializerFormat] in the interface it will not change the names in the proxy generated.

sergiosp