Problem with minOccurs="0" in client WSDL

Ask a Question related to ASP.NET Web Services, Design and Development.

  1. #1

    Default Problem with minOccurs="0" in client WSDL

    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 Guest

  2. Similar Questions and Discussions

    1. WebService "Unable to load WSDL" error
      I need some help with this strange problem I have a web service that i call from Flex 3 <mx:WebService id="dataTowns"...
    2. WSDL Minoccurs changes when nil="true" is set.
      Hi, can someone tell me why the following scneario occurs. With the nillable attribute set to true on an element that has min occurs set to zero, I...
    3. How to have a "fault" element in generated WSDL?
      I have a standard web method in a standard asmx web service. Say: public string mySimpleMethod(string data){ try { . . . . . . } catch...
    4. OVERride "binding" name and "portType" name in WSDL
      Can anyone suggest how we can override the generated "binding" name and "portType" name attributes in the generated WSDL document? i.e. VS.NET...
    5. ANN: Improve your "Contract First" Web services development experience: WsContractFirst v0.2 - forget about wsdl.exe
      OK, here we go ... I am happy to announce version 0.2 of a tool - a Visual Studio .NET Add-In - called WsContractFirst. The first bits (version 0.1)...
  3. #2

    Default Re: Problem with minOccurs="0" in client WSDL

    "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.

    Mike wrote:
    > 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
    >
    >
    --
    HTH
    Regards,
    Dilip Krishnan
    MCAD, MCSD.net
    dkrishnan at geniant dot com
    [url]http://www.geniant.com[/url]
    Dilip Krishnan Guest

  4. #3

    Default Re: Problem with minOccurs="0" in client WSDL

    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

    "Dilip Krishnan" <dkrishnan@NOSPAM.geniant.com> wrote in message
    news:%23zeQzKgHFHA.2704@tk2msftngp13.phx.gbl...
    > "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.
    >
    > Mike wrote:
    >> 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
    >
    > --
    > HTH
    > Regards,
    > Dilip Krishnan
    > MCAD, MCSD.net
    > dkrishnan at geniant dot com
    > [url]http://www.geniant.com[/url]

    Mike Guest

  5. #4

    Default RE: Problem with minOccurs="0" in client WSDL

    This is a know issue for value types in 1.0 and 1.1 of the .NET framework.

    If I understand you, your service will always send this value. If that is
    the case, then you can receive your message and then just access the data.
    The Specified flag tells you if the data was sent - it is to prevent you
    from reading data that is not initialized by the sender.

    If you want to make this work as is, and get specified working, make it an
    attribute on the service interface. This gets around the known issue.

    --------------------
    >From: "Mike" <mraeNOSPAM@NOSPAMATALLcalibrus.com>
    >Subject: Problem with minOccurs="0" in client WSDL
    >Date: Mon, 28 Feb 2005 18:39:14 -0700
    >Lines: 33
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >X-RFC2646: Format=Flowed; Original
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >Message-ID: <#cvz69fHFHA.3484@TK2MSFTNGP12.phx.gbl>
    >Newsgroups:
    microsoft.public.dotnet.framework.aspnet.webservic es,microsoft.public.dotnet
    framework.webservices
    >NNTP-Posting-Host: 206-169-51-163.gen.twtelecom.net 206.169.51.163
    >Path:
    TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP1
    2.phx.gbl
    >Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.webservices:9491
    microsoft.public.dotnet.framework.aspnet.webservic es:28340
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    >
    >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
    >
    >
    >
    Dan Rogers Guest

  6. #5

    Default Re: Problem with minOccurs="0" in client WSDL

    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


    "Dan Rogers" <danro@microsoft.com> wrote in message
    news:QvPETu0IFHA.1140@TK2MSFTNGXA02.phx.gbl...
    > This is a know issue for value types in 1.0 and 1.1 of the .NET
    > framework.
    >
    > If I understand you, your service will always send this value. If that is
    > the case, then you can receive your message and then just access the data.
    > The Specified flag tells you if the data was sent - it is to prevent you
    > from reading data that is not initialized by the sender.
    >
    > If you want to make this work as is, and get specified working, make it an
    > attribute on the service interface. This gets around the known issue.
    >
    > --------------------
    >>From: "Mike" <mraeNOSPAM@NOSPAMATALLcalibrus.com>
    >>Subject: Problem with minOccurs="0" in client WSDL
    >>Date: Mon, 28 Feb 2005 18:39:14 -0700
    >>Lines: 33
    >>X-Priority: 3
    >>X-MSMail-Priority: Normal
    >>X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >>X-RFC2646: Format=Flowed; Original
    >>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >>Message-ID: <#cvz69fHFHA.3484@TK2MSFTNGP12.phx.gbl>
    >>Newsgroups:
    > microsoft.public.dotnet.framework.aspnet.webservic es,microsoft.public.dotnet
    > framework.webservices
    >>NNTP-Posting-Host: 206-169-51-163.gen.twtelecom.net 206.169.51.163
    >>Path:
    > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP1
    > 2.phx.gbl
    >>Xref: TK2MSFTNGXA02.phx.gbl
    > microsoft.public.dotnet.framework.webservices:9491
    > microsoft.public.dotnet.framework.aspnet.webservic es:28340
    >>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    >>
    >>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 Guest

  7. #6

    Default Re: Problem with minOccurs="0" in client WSDL

    The other thing you can do on your side is to remove the Specified variable
    for this field. That would make it always get serialized.

    I'm not clear on whether your program is creating the XML that is a problem
    (you need to set the specified flag to true once you set the field.
    Properties are perfect for doing this as follows:

    [XmlElementAttribute(name="foo")]
    public fooEnum foo;
    public bool fooSpecified;

    [XmlIgnore]
    public fooEnum fooProperty
    {
    get {return foo;}
    set { foo = value; fooSpecified=true;}
    }

    Since you control the proxy you use, you can control all of this code on
    this side.

    --------------------
    >From: "Mike" <mraeNOSPAM@NOSPAMATALLcalibrus.com>
    >References: <#cvz69fHFHA.3484@TK2MSFTNGP12.phx.gbl>
    <QvPETu0IFHA.1140@TK2MSFTNGXA02.phx.gbl>
    >Subject: Re: Problem with minOccurs="0" in client WSDL
    >Date: Tue, 8 Mar 2005 09:54:51 -0700
    >Lines: 99
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >X-RFC2646: Format=Flowed; Original
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >Message-ID: <uuuoM#$IFHA.3336@TK2MSFTNGP10.phx.gbl>
    >Newsgroups:
    microsoft.public.dotnet.framework.aspnet.webservic es,microsoft.public.dotnet
    ..framework.webservices
    >NNTP-Posting-Host: 206-169-51-163.gen.twtelecom.net 206.169.51.163
    >Path:
    TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP1
    0.phx.gbl
    >Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.webservices:9680
    microsoft.public.dotnet.framework.aspnet.webservic es:28497
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    >
    >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
    >
    >
    >"Dan Rogers" <danro@microsoft.com> wrote in message
    >news:QvPETu0IFHA.1140@TK2MSFTNGXA02.phx.gbl...
    >> This is a know issue for value types in 1.0 and 1.1 of the .NET
    >> framework.
    >>
    >> If I understand you, your service will always send this value. If that
    is
    >> the case, then you can receive your message and then just access the
    data.
    >> The Specified flag tells you if the data was sent - it is to prevent you
    >> from reading data that is not initialized by the sender.
    >>
    >> If you want to make this work as is, and get specified working, make it
    an
    >> attribute on the service interface. This gets around the known issue.
    >>
    >> --------------------
    >>>From: "Mike" <mraeNOSPAM@NOSPAMATALLcalibrus.com>
    >>>Subject: Problem with minOccurs="0" in client WSDL
    >>>Date: Mon, 28 Feb 2005 18:39:14 -0700
    >>>Lines: 33
    >>>X-Priority: 3
    >>>X-MSMail-Priority: Normal
    >>>X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    >>>X-RFC2646: Format=Flowed; Original
    >>>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    >>>Message-ID: <#cvz69fHFHA.3484@TK2MSFTNGP12.phx.gbl>
    >>>Newsgroups:
    >>
    microsoft.public.dotnet.framework.aspnet.webservic es,microsoft.public.dotnet
    >> framework.webservices
    >>>NNTP-Posting-Host: 206-169-51-163.gen.twtelecom.net 206.169.51.163
    >>>Path:
    >>
    TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP1
    >> 2.phx.gbl
    >>>Xref: TK2MSFTNGXA02.phx.gbl
    >> microsoft.public.dotnet.framework.webservices:9491
    >> microsoft.public.dotnet.framework.aspnet.webservic es:28340
    >>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
    >>>
    >>>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
    >>>
    >>>
    >>>
    >>
    >
    >
    >
    Dan Rogers Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139