Question:
I created a WCF service that exposed a method this has one paramater:
public class Service1:iservice1
{
public string GetData (int value)
{
return string. Format ("you entered: {0}", value);
}
}
The service has both endpoints defined (Wshttpbinding and basichttpbinding) so that it would is compatable with older Clien Ts.
The service runs just fine in a. NET 3.0 and. NET 3.5 client app. However, when I create a. NET 2.0 client, the GetData method requires 2 Parameters:an integer (expected) and a bool param Eter called valuespecified (unexpected). I never defined the second parameter. Why are this happening and how can I get rid of the second parameter?
Answer:
Another-Avoid the extra Boolean parameter to being generated on the client proxy when using. NET 2.0 are to switch to C0>rpc-style enconding in the service contract (the default for both WCF and ASMX is Document style).
This is the XmlSerializer on the client would make sure, the parameter always appears in the SOAP request s since it's part of the SOAP 1.1 specification, which was enforced when using the Rpc-style encoding.
In WCF can specify the encoding style using the Datacontractformat attribute, either at the service or at the Operatio N level.
[ServiceContract]
public interface IService
{
[OperationContract]
[Datacontractformat (Style = OPERATIONFORMATSTYLE.RPC)]
string GetData (int value);
}
More information on the differences between RPC style and Document Style encoding in SOAP can is found here.
In consider carefully the implications of changing the contract of your services, since it can potentially Break compatibility with any existing clients.
Web Reference for a WCF Service have Extra "idspecified" Parameter?