473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

minOccurs from VB code - attribute?

In a VB.Net webservice, after adding a data class, members of type String
get a "minOccurs=0" attribute in the generated WSDL.

Is there an attribute you can apply to the definition, or some other way to
turn this into "minOccurs=1"?
For example, in this class:

<WebService(Namespace:=...)> _
public class MyWebService
Inherits System.Web.Services.WebService

<WebMethod()> Public Sub TestFunc(byval t as TestData)
....
End Sub

public class TestData
Public Name as string
end class

end class

the "Name" member of TestData comes out in WSDL as

<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
I'd like to get minOccurs="1" instead, so clients can understand that the
value isn't optional.

I've tried playing around with the IsNullable attribute through
SystemXml.Serialization.XmlElementAttribute and
System.Xml.Serialization.SoapElement, but it makes no difference.
Jun 16 '06 #1
1 3439
Hi

If you set the IsNullable to true on the XmlElement attribute (in c#):

[XmlElement(IsNullable=true)]
public string MyString

You will get the desired minOccurs=1 attribute. However, this doesn't
stop clients from
sending nulls strings like this:

<MyString xsi:nil="true">

So you'll also need to manually validate the input and throw an error,
but that's easy enough.

Josh
http://www.thejoyofcode.com/
Lucvdv wrote:
In a VB.Net webservice, after adding a data class, members of type String
get a "minOccurs=0" attribute in the generated WSDL.

Is there an attribute you can apply to the definition, or some other way to
turn this into "minOccurs=1"?
For example, in this class:

<WebService(Namespace:=...)> _
public class MyWebService
Inherits System.Web.Services.WebService

<WebMethod()> Public Sub TestFunc(byval t as TestData)
....
End Sub

public class TestData
Public Name as string
end class

end class

the "Name" member of TestData comes out in WSDL as

<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
I'd like to get minOccurs="1" instead, so clients can understand that the
value isn't optional.

I've tried playing around with the IsNullable attribute through
SystemXml.Serialization.XmlElementAttribute and
System.Xml.Serialization.SoapElement, but it makes no difference.


Jun 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lee Atkinson | last post by:
Hi What effect does the presence of minOccurs attribute with columns defining the tables for a dataset? I understand that, if it is set to minOccurs=0, then the element does not have to appear...
2
by: joewhitehair | last post by:
Using the XSD.exe tool, I created a number of classes from my XSD file. When I generate the WSDL for my web service, the schema does not have the proper Occurance constraints for the attributes. In...
0
by: Robert Rae | last post by:
Does anyone know of a way to set minoccurs and maxoccurs from an attribute. An example would be: public string HelloWorld(DataInput dataInput) { return "Hello World"; } public class...
0
by: John Jenkins | last post by:
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 generate a class. As expected this adds the...
0
by: John Jenkins | last post by:
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 generate a class. As expected this adds the...
0
by: John Jenkins | last post by:
Hi, apologies for tghe repost, but I cannot get an answer to my question and I have noe posted on 7 news groups. Can someone tell me why the following scneario occurs. With the nillable attribute...
7
by: rbarschaw | last post by:
I have the following schema designed: <xs:complexType name="AzzFeature-BoxType" mixed="true"> <xs:choice minOccurs="1" maxOccurs="unbounded"> <xs:element ref="Sub-Head" minOccurs="1"...
0
by: Lucvdv | last post by:
In a VB.Net webservice, after adding a data class, members of type String get a "minOccurs=0" attribute in the generated WSDL. Is there an attribute you can apply to the definition, or some other...
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.