By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,784 Members | 1,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,784 IT Pros & Developers. It's quick & easy.

Boolean parameter maps to two separate parameters in proxy?

P: n/a
I have a wsdl file that I received from a third party and I'm using wsdl.exe
(.NET 2.0) to import it and generate a proxy class. I've actually got a
proxy class that works, but I'm trying to understand why wsdl.exe did what
it did and whether or not the complexity it's added to the interface is
necessary or avoidable.

The wsdl file specifies a Boolean parameter pAggregatePurses for one of the
web service methods. In the proxy class method that is represented by two
separate parameters:

<System.Xml.Serialization.XmlElementAttribute(IsNu llable:=true)> ByVal
pAggregatePurses As System.Nullable(Of Boolean)

and

<System.Xml.Serialization.XmlElementAttribute(IsNu llable:=true),
System.Xml.Serialization.XmlIgnoreAttribute()> ByVal
pAggregatePursesSpecified As Boolean

I can't see anything in the wsdl file that would result in this method
signature. Is this normal behavior for the wsdl.exe utility when dealing
with Boolean parameters? Is it necessary? Can anyone explain why it works
the way it does?

Thanks,
Zoe
Jun 22 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Hello Zoe,

I just test a simple web service with boolean parameters, but I didn't find
two separate parameters in the proxy class. So I think this should be
related to the WSDL file you got. Is it possible for you to provide the
WSDL file, to narrow down the problem?

Regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jun 23 '06 #2

P: n/a
Luke,

The WSDL is not mine and may contain information proprietary to the web
service provider and or my client, the web service consumer. But I've been
taking another look at it and have a guess as to what's happening. Along
with the WSDL I get a set of XML and XSD files that provide supporting
definitions. One of the XSD files provides the definition of a type that
represents the full set of input parameters for the method I'm working with.
That type definition is for a complex type and the parameter in question is
one element of that complex type. The element definition with the XSD looks
like this:

<xsd:element name="someName" type="xsd:boolean" nillable="true"
minOccurs="0" />

I wonder if it's the combination of the type="xsd:boolean" and the
nillable="true" attributes. Since a boolean isn't normally nullable, you
need two pieces of information - 1) whether or not a value has been set and
2) the actual value which is only valid when the (1) is True. Even so the
type of System.Nullable(Of Boolean) seems to cover both pieces of
information within the elements of the System.Nullable type, so I'm still a
bit confused as to why the WSDL.exe tool generated a whole new, separate
parameter to indicate whether or not a value had been supplied.

Thanks,
Zoe

"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:2Y**************@TK2MSFTNGXA01.phx.gbl...
Hello Zoe,

I just test a simple web service with boolean parameters, but I didn't
find
two separate parameters in the proxy class. So I think this should be
related to the WSDL file you got. Is it possible for you to provide the
WSDL file, to narrow down the problem?

Regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 26 '06 #3

P: n/a
Hello,

The main difference between the sepeated parameters is:
System.Xml.Serialization.XmlIgnoreAttribute(), which indicate not to
serialize the parameter. I think this may be related to:

minOccurs="0"

How do you think about this?

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jun 27 '06 #4

P: n/a
Luke,

I could be wrong, but I don't think the minOccurs="0" is the problem. Here's
the definition of another parameter to the same method:

<xsd:element name="anotherParameter" type="outNamespace:someType"
nillable="true" minOccurs="0" />

This parameter is also nullable with minOccurs="0". The main difference
between this parameter and the one that generates two parameters is the
type. This one is an object type defined elsewhere in the XSD, while the
other is a Boolean. I think the wsdl utility generates the somewhat
complicated parameters it does for the nullable Boolean parameter because
the CLR doesn't allow a null value for a Boolean type. If you generate a
WSDL with a nullable (nillable="true") Boolean parameter, can you reproduce
what I'm seeing with the dual proxy parameters representing a single acutal
parameter?

Thanks,
Zoe

"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:ba**************@TK2MSFTNGXA01.phx.gbl...
Hello,

The main difference between the sepeated parameters is:
System.Xml.Serialization.XmlIgnoreAttribute(), which indicate not to
serialize the parameter. I think this may be related to:

minOccurs="0"

How do you think about this?

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 27 '06 #5

P: n/a
Hi Zoe,

I create a test webservie with following web method:

<WebMethod()> _
Public Function GetString(ByVal b As System.Nullable(Of Boolean)) As
String
Return "Hello"
End Function

But WSDL.exe still only generated one function definition in the proxy
class. Can you share a sample of the web method?

BTW, I work with WSDL.exe in VS.NET 2005.

Thanks,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jun 28 '06 #6

P: n/a
Unfortunately I don't have visibility into what the web service code looks
like - only what the resulting wsdl file looks like. I'll send you the wsdl
offline to see if you can see what in it is causing this overly complex
proxy class. I've recently run into another issue with a similar property.
In this case the proxy again uses two separate values to represent what is a
single value (this time a Long) in the wsdl. In this case it was an output
parameter not an input parameter and from what I've been able to tell in my
testing the "xyzSpecified" parameter generated by the proxy is not reliably
populated. xyzSpecified appears to be False even when the xyz output
parameter comes back with a value. I can code around all this but a) it's a
hassle and b) I'm concerned about the longterm reliability and
maintainability of code that's based on things like "xyzSpecified appears to
be False even when the xyz output parameter comes back with a value". It
feels like I'm coding around a bug instead of understanding and correcting
it and in my experience that is rarely a good idea.

Zoe

"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:Hb**************@TK2MSFTNGXA01.phx.gbl...
Hi Zoe,

I create a test webservie with following web method:

<WebMethod()> _
Public Function GetString(ByVal b As System.Nullable(Of Boolean)) As
String
Return "Hello"
End Function

But WSDL.exe still only generated one function definition in the proxy
class. Can you share a sample of the web method?

BTW, I work with WSDL.exe in VS.NET 2005.

Thanks,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 29 '06 #7

P: n/a
Hi Zoe,

I have receive your message. I will study the WSDL file and update you as
soon as possible.

Regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jun 30 '06 #8

P: n/a
Hi Zoe,

I made some progress and here is the update:

I remove minOccurs="0" from the xsd file and generate a vb file again, and
then I got only one parameter in the function definition. This also
happened if I change to minOccurs="1". So I believe the problem should be
with minOccurs="0" here.

The parameter's value is determined by two

pAggregatePursesSpecified : means "Occurs"
pAggregatePurses: actual value.
Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jun 30 '06 #9

P: n/a
Thanks Luke. I'll get in touch with the folks who own the web service and
the wsdl and determine if it these parameters are truly minOccurs=0. If so,
then maybe I'm stuck with the complex interface in the proxy class, but if
not, we can clean up the wsdl and simplify the proxy. Thanks again for your
help.

Zoe

"Luke Zhang [MSFT]" <lu******@online.microsoft.com> wrote in message
news:Dv**************@TK2MSFTNGXA01.phx.gbl...
Hi Zoe,

I made some progress and here is the update:

I remove minOccurs="0" from the xsd file and generate a vb file again, and
then I got only one parameter in the function definition. This also
happened if I change to minOccurs="1". So I believe the problem should be
with minOccurs="0" here.

The parameter's value is determined by two

pAggregatePursesSpecified : means "Occurs"
pAggregatePurses: actual value.
Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jun 30 '06 #10

P: n/a
Thank you for the reply. If there is any further questions, please feel
free to post here.

regards,

Luke Zhang
Microsoft Online Community Lead

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Jul 3 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.