473,394 Members | 1,703 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,394 software developers and data experts.

C# webservice - wrong minOccurs spec on WSDL ?

Consider the following C# webservice code and the corresponding WSDL
generated by .NET:

C# Webservice (Fragment)
================
...
public struct SSS
{
[XmlElement("AAA")] public decimal aaa ;
[XmlElement("BBB")] public string bbb ;
}
....
public int (SSS args) {

WSDL (Fragment)
==============
...
<s:complexType name="SSS">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AAA"
type="s:decimal" />
<s:element minOccurs="0" maxOccurs="1" name="BBB"
type="s:string" />
</s:sequence>
</s:complexType>
...

My problem is: I don't understand why the element AAA is marked as
mandatory while BBB is left as optional on the WSDL description. And
worst,
I don't understand why, despite this, a SOAP request without any AAA
element is
considered Ok by the webservice - I thought the absence of an AAA
element on
the SOAP request would trigger an error.

Jul 31 '07 #1
8 5671
On Tue, 31 Jul 2007 04:59:05 +0200, <rt***@hotmail.comwrote:
Consider the following C# webservice code and the corresponding WSDL
generated by .NET:

C# Webservice (Fragment)
================
...
public struct SSS
{
[XmlElement("AAA")] public decimal aaa ;
[XmlElement("BBB")] public string bbb ;
}
....
public int (SSS args) {

WSDL (Fragment)
==============
...
<s:complexType name="SSS">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AAA"
type="s:decimal" />
<s:element minOccurs="0" maxOccurs="1" name="BBB"
type="s:string" />
</s:sequence>
</s:complexType>
...

My problem is: I don't understand why the element AAA is marked as
mandatory while BBB is left as optional on the WSDL description. And
worst,
I don't understand why, despite this, a SOAP request without any AAA
element is
considered Ok by the webservice - I thought the absence of an AAA
element on
the SOAP request would trigger an error.
string is a nullable type where decimal not....

Mrozik
Jul 31 '07 #2
>
string is a nullable type where decimal not....
Ok. But what I also said is that, despite this, a SOAP request WITHOUT
the AAA element (ie., the thought mandatory decimal element) is
considered valid (and the value 0 (zero) is assigned to the variable
'aaa'). If so, why not mark it as optional on the WSDL? And more ..
If zero is the implicit default value for decimal types, why this is
not reflected on the generated WSDL. I think that the 'correct' WSDL
for this element would have 'minOccurs=0' and 'default=0'. By the way,
is there any way of modifying the WSDL serialization proccess so to
have this mentioned syntax as the result?
Jul 31 '07 #3
On Tue, 31 Jul 2007 14:57:22 +0200, <rt***@hotmail.comwrote:
>>
string is a nullable type where decimal not....

Ok. But what I also said is that, despite this, a SOAP request WITHOUT
the AAA element (ie., the thought mandatory decimal element) is
considered valid (and the value 0 (zero) is assigned to the variable
'aaa'). If so, why not mark it as optional on the WSDL? And more ..
If zero is the implicit default value for decimal types, why this is
not reflected on the generated WSDL. I think that the 'correct' WSDL
for this element would have 'minOccurs=0' and 'default=0'. By the way,
is there any way of modifying the WSDL serialization proccess so to
have this mentioned syntax as the result?

because default value of decimal variable is 0 - try use decimal? datatype
if you want to send null value to WS and check if paremeter was set.
Mrozik
Jul 31 '07 #4
I understand that 0 is the default value for decimal datatypes. But
that is not the problem. The problem is that the .NET serialized WSDL
is WRONG. And It's causing me problems with some Java clients
(developed by another company) that are trying to access my
webservice. Basically the client software is reading my WSDL and
understanding that AAA (the decimal element) is mandatory, refusing to
make the request when no value is available for AAA (while it would be
perfectly OK to send the request without AAA, as it's proved that it
would cause no error). So the solution would be to provide a 'correct'
WSDL, ie., one that had AAA marked as optional (with minOccurs=0
instead of minOccurs=1). But I don't know how to do that.

Jul 31 '07 #5
<rt***@hotmail.comwrote in message
news:11*********************@k79g2000hse.googlegro ups.com...
>I understand that 0 is the default value for decimal datatypes. But
that is not the problem. The problem is that the .NET serialized WSDL
is WRONG. And It's causing me problems with some Java clients
(developed by another company) that are trying to access my
webservice. Basically the client software is reading my WSDL and
understanding that AAA (the decimal element) is mandatory, refusing to
make the request when no value is available for AAA (while it would be
perfectly OK to send the request without AAA, as it's proved that it
would cause no error). So the solution would be to provide a 'correct'
WSDL, ie., one that had AAA marked as optional (with minOccurs=0
instead of minOccurs=1). But I don't know how to do that.
But it _would_ cause an error if AAA was not sent. That would violate the
WSDL and probably cause an error during deserialization.

Perhaps you'd like the WSDL to indicate that AAA is nillable. Have you tried
to declare AAA as "decimal?"
--
John Saunders [MVP]

Jul 31 '07 #6
But it _would_ cause an error if AAA was not sent. That would violate the
WSDL and probably cause an error during deserialization.
That's exactly the point - there's NO error when AAA is absent
(because it has an implicit default value).

I think we should analyse who cames first, the program or the WSDL. In
this case, the program cames first, and for this particular program
AAA is an OPTIONAL element - it can be supressed from the request with
no consequence but the use of AAA default value. So, in my opinion,
the .NET automatically generated WSDL is wrong, as it does not have
AAA marked as an optional element. If the oposite was true (WSDL
first, with AAA marked as mandatory, as a requirement for the
program), the program should trigger an exception on the absence of
AAA (but it doesn't).
Perhaps you'd like the WSDL to indicate that AAA is nillable. Have you tried
to declare AAA as "decimal?"
Yes, I think this can be a solution. The problem is that the client
software is not able to understand the 'nillable="true"' declaration.
It only looks for "minOccurs=0" or "minOccurs=1". I will declare AAA
as "decimal?" and try to convince then to refine their software.

Thanks all for helping me on this subject


Jul 31 '07 #7
I tryed the use of the "decimal?" datatype (in this case the
'isNillable="true"' declaration is serialized) but a SOAP request with
'<AAA xsi:nil="true" />' triggers the following error: "Input string
was not in a correct format."

Jul 31 '07 #8
<rt***@hotmail.comwrote in message
news:11*********************@d55g2000hsg.googlegro ups.com...
>I tryed the use of the "decimal?" datatype (in this case the
'isNillable="true"' declaration is serialized) but a SOAP request with
'<AAA xsi:nil="true" />' triggers the following error: "Input string
was not in a correct format."
Can you include the full stack trace, please? I'm interested in seeing which
piece of code it is that complains about the format.
--
John Saunders [MVP]

Aug 1 '07 #9

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

Similar topics

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...
6
by: Markus Eßmayr | last post by:
Hello, I'd like to consume a WebService, which returns an array of objects which include several members of type System.String, System.Decimal and System.DateTime. In the WSDL-file, the members...
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
0
by: leslie_tighe | last post by:
Hello, I have a web service that is running in a java server using axis that I want to use from .net. In VS.net 2003 I setup a project with a web reference. Using generated code I am able to...
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
0
by: Thomas.Koerfer | last post by:
Hey guys, I googled for nearly 3 hours - but no result... We run a web-service and want to reach that service from Access. In the following part you see the wsdl content and the automatically...
0
by: vr6stress | last post by:
I've run into a snag on a webservice. It's looking for a type of ArrayofString. Bascially it want multiple numbers (bar_code_numbers) to redeem. I swear I had the array built right...but it keeps...
1
by: gah | last post by:
I am getting an array of records from an asp.net webservice and wanting to display them in a dynamically created html table in the php page. I am new to php and not sure how to get the values from...
0
by: lehu | last post by:
Hi, I have created web service, it's practically finished, but I wanted to do some improvements in generated wsdl: - For string parameters i get element tag such as this in wsdl: <s:element...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.