Question

I am using Visual Studio 2012 to auto generate a proxy class to a WCF service. In the service contract, one of the methods, GetActiveSessions(), is defined as returning a Dictionary<Guid, Session>, but here's how the property appears in my proxy class:

public MyNamespace.ArrayOfKeyValueOfguidSessionxjDRWaWoKeyValueOfguidSessionxjDRWaWo[] GetActiveSessions() {
    ....
}

There's also another instance of this strange behavior where a service method that is supposed to return a Guid is defined as returning a string in my proxy class. While the methods seems to work as specified when I used the methods as defined by the proxy class, I'd like to not have to work with objects of type ArrayOfKeyValueOfguidSessionxjDRWaWoKeyValueOfguidSessionxjDRWaWo in my code.

Any ideas as to what is causing this strange behavior?

Était-ce utile?

La solution

This is expected behavior. The proxy serialized wire format will match the schems defined in the WSDL/XSD. However there are many anonymous types and arrays in the WSDL which have no name and when you work with a proxy you need to name them. So WCF calculates a unique name by chaining names across the element path. If you want a different name then either create a wrapper on top of the proxy (and maintain it) or don't use anonymous types in the WSDL.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top