c# - VS2003 Web Reference for a WCF Service has Extra "IdSpecified" Parameter -
I am developing a WCF service using VSTS 2008 + .NET 3.5 + C # and whenever I use VSTS 2008 Use the Client Developer (Automatically use the add-on service reference function for the generated client web service) I am using WCF Basic HttpBinding.
The issue I found is that when I use Visual Studio .Net (Visual Studio 2003) to generate the client web service proxy code, an additional input parameter operation contract method Which is called ID Explanation I have tested that when IDs are specified on the right, the value of the ID parameter will be passed correctly to the WCF server, but when I id on the wrong Then specifies whether the values that I have ID specifies parameters, WCF server side, the ID is always 0. I have no additional input parameter that tried input parameter types like string, the client-side.
My question is why is there an extra parameter? What does it mean and is it possible to avoid generating such additional parameters?
Visual Studio.Net automatically generates client-side web service proxy code,
public StudentInfo Poll (Ent ID, [System.Xml.Serialization.XmlIgnoreAttribute ()] Bool IdSpecified
Here is my VSTS 2008 WCF server side code,
[Operation Contract] Student Info Poll (Int ID); Edit 1: Here is a part of the code generated automatically on the client side about the pole method. [Return: System.xml.Serialization.XmlElementAttribute (IsNullable = true)] Public Student Info Pole (Ent ID, [System.Xml.Serialization.XmlIgnoreAttribute ()] bool IdSpecified {Object} ] Results = this.Invoke ("Polling", New Object [] {ID, IdSpecified}); Return (scholarship) (Results [0])); George,
George,
This behavior is in accordance with the design, And since the net 1.0 is there. In fact, if you want to create an ASMX web service with VS 2003, then with the signature of the same method, you will get the same result.
The problem is with the value type which are not marked in the WSDL. Since they are value types, they can not return to zero (and VS 2003 are not the null type). The solution implemented by Microsoft was to add a different Boolean field or property that you can set to say whether you are supplying the price or not.
This means that when your .NET 1.1 application service wants to call, it needs to set the parameter specifying the ID:
using ( WebReference1.PollService svc = New WebReference1.PollService ()) {StudentInfo info = svc.Poll (id, true); // is correct to specify)
I have not tried to do this, but why do not you:
[DataContract ] Public class PollParameters {[Datamember (required = true)] Public Ent ID; } [Operation Contract] Public Student Invoice Poll (Poll parameter parameter);
Try it out and see what the proxy looks like in VS2003.
Comments
Post a Comment