Groups | Blog | Home
all groups > dotnet web services > february 2005 >

dotnet web services : Problem with minOccurs="0" in client WSDL


Mike
2/28/2005 6:39:14 PM
I have created a web service for a client to consume. The element I am
having trouble with is, as described in their WSDL:

<xsd:element minOccurs="0" ref="LocalData" maxOccurs="1" />

<xsd:element name="LocalData">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Y" />
<xsd:enumeration value="N" />
</xsd:restriction base="xsd:string">
</xsd:simpleType>
</xsd:element>

When I created a class around this it created a LocalDataSpecified bool.
This bool needs to be set in order for my web service to properly handle the
object.

The problem is, is that the client isn't so much "consuming" the web service
in a developement environment like VS.NET 2003, but rather just throwing
SOAP messages at it. So when I get the message LocalData might specified
but the "LocalDataSpecified" flag is not getting set so I can't tell how to
handle it. The value defaults to "Y" because it is declared at the top of
the enumeration.

Is there any attributes I need to set or any thing else in general that I am
missing?

Thanks a lot for your help.

Mike R

Mike
2/28/2005 7:18:49 PM
That is what I assumed happed. But regardless if I set the element or not
the LocalDataSpecified always comes across as false. The only way I have
been able to get LocalDataSpecified = true is by setting it myself in the
program calling the web service.

Mike

[quoted text, click to view]

Dilip Krishnan
2/28/2005 8:02:23 PM
"LocalDataSpecified" is a technique specfic to .net so the serializer
sets the boolean variable to true ONLY if the Localdata element is found
in the incoming message. So if the Specified is false then the element
dint come in.

[quoted text, click to view]

--
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
Mike
3/8/2005 9:54:51 AM
Thanks for the response.

The problem I have here is really the client. They cannot make any changes
to their web service because of their development cycle will push the
project back 3 months. I'm having to back my code into a poorly designed
and poorly written web service.

One work around I was looking at doing was to default LocalDataSpecified to
true then add an 'X' value to the top of the LocalData enum. That way
unless they specify 'Y' or 'N' it will default to 'X' so I know they didn't
choose anything. And since they are just pushed raw XML to my web service
instead of calling it from a development environment, this also should be
transparent to them.

Not the best fix but it is all I've come up with. Any other suggestions on
how I can fix this on my side would be appreciated.

Thanks,

Mike R


[quoted text, click to view]

AddThis Social Bookmark Button