BUG: Web Method Parameters Are Mismatched if You Pass a Null Parameter When You Call a Web Service (318037)
The information in this article applies to:
- Microsoft Web Services (included with the .NET Framework) 1.0
- Microsoft Web Services (included with the .NET Framework 1.1)
This article was previously published under Q318037 SYMPTOMSNote The following .NET Framework Class Library namespaces are
referenced in this article:
System.Web.Services
ASP.NET XML
Web services allow you to control the formatting and call style of methods in a
Web service. You can control this behavior by using attributes applied to the
Web methods in the Web service. However, values that are incorrectly matched
with the parameters in the Web service may be passed to the Web service by a
.NET client. For example, the Web service may serialize the second parameter
passed by the client into the first parameter of the Web service.
CAUSE One particular call style and formatting selection can
cause the values passed to the Web service by a .NET client to be incorrectly
matched with the parameters in the Web service. This issue can occur if you
specify a Document style Web method with Encoded and Bare parameters. Additionally, the Web method must have multiple
parameters of the same type. If a client application uses a .NET client proxy
to call such a Web service, and one of the parameters that is not at the end of
the parameter list is null (or Nothing, if you are using Microsoft Visual Basic .NET), this issue
occurs. The positions of the parameters after the null parameter that the Web service receives are shifted down the
parameter list, and the wrong values are serialized into the parameters of the
Web method.
The Web method parameters in SOAP messages that clients
send for the Web method style described in the first paragraph of the "Cause"
section of this article have no information associated with them that indicates
which Web method parameters they correspond to. Therefore, ASP.NET Web services
rely on the position of the parameters in the message to match them with the
correct Web method parameters. If a client passes null for one of them, nothing is sent for that parameter. Because the null parameter is missing, the following parameter assumes the
position of the missing parameter, and therefore ASP.NET incorrectly matches
the parameter in that position with the corresponding Web method parameter.
RESOLUTION To work around this issue, do not specify the Encoded and Bare parameters for your Document style Web methods. If you need to
implement those kinds of Web methods, avoid giving them multiple parameters of
the same type, or make sure that client applications do not pass null for method parameters when they make calls. STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 7/8/2005 |
---|
Keywords: | kbBug kbCaching kbConfig kbCtrlCreate kbDataBinding kbDebug kbDeployment kbHttpRuntime kbLocalization kbPerformance kbScalability kbSecurity kbServerControls kbState kbUpgrade kbValidation kbWebForms KB318037 |
---|
|