Web Reference for a WCF Service have Extra "idspecified" Parameter?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.