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

wsdl.exe support for Nillable Value Types within WSDL

I have a WebService whose WSDL contains the following snippet:

<complexType abstract="true" name="Type">
<sequence>
<element name="localId" nillable="true" type="xsd:string"/>
<element name="id" minOccurs="0" maxOccurs="1" nillable="true"
type="xsd:int"/>
</sequence>
</complexType>

When I run wsdl.exe against this, the following C# code is generated:

public abstract class Type {
public string localId;
public int id;
}

Unfortunately, the "id" element is incapable of holding null / nil
values because it is a Value Type (int). If the client specifies
nothing, the value sent is zero(0) which is incorrect and violates the
XML Schema.

I will be providing this WSDL to my clients ... they will be building
their own Web Service Clients using tools including wsdl.exe.

How do I workaround wsdl.exe's apparant "lack of support" for
'nillable="true"' and 'minOccurs="0"'?

Thanks in advance.
Jul 21 '05 #1
2 2546
One solution (the one I took) is to manually alter the generated code to use
an object reference rather than a value type:

public class Type {
public string localId;
public object id;
}

Obviously you'll have to cast where not null. You could also maybe use the
types defined in System.Data.SqlTypes which are nillable.

HTH,
Kent

A nicer solution would be for wsdl.exe to do this for you. I'm not sure if
there are plans to fix this in future .NET releases.

"Erik Klein" <Er*******@yahoo.com> wrote in message
news:f2*************************@posting.google.co m...
I have a WebService whose WSDL contains the following snippet:

<complexType abstract="true" name="Type">
<sequence>
<element name="localId" nillable="true" type="xsd:string"/>
<element name="id" minOccurs="0" maxOccurs="1" nillable="true"
type="xsd:int"/>
</sequence>
</complexType>

When I run wsdl.exe against this, the following C# code is generated:

public abstract class Type {
public string localId;
public int id;
}

Unfortunately, the "id" element is incapable of holding null / nil
values because it is a Value Type (int). If the client specifies
nothing, the value sent is zero(0) which is incorrect and violates the
XML Schema.

I will be providing this WSDL to my clients ... they will be building
their own Web Service Clients using tools including wsdl.exe.

How do I workaround wsdl.exe's apparant "lack of support" for
'nillable="true"' and 'minOccurs="0"'?

Thanks in advance.

Jul 21 '05 #2
Thanks for the suggestions.

I have already modified the code to use object instead of int.
Unfortunately, that eliminates the whole purpose for me specifying "int"
in the WSDL in the first place ... I wanted strict type casting. That
is now gone.

<< You could also maybe use the
types defined in System.Data.SqlTypes which are nillable.>>

Regrettably, these are not Serializable and therefore .NET can't
transmit them as XML to a Web Service.

<<A nicer solution would be for wsdl.exe to do this for you.>>

I personally believe that a "nicer solution" would be for Dot-Net to
join the rest of the world in recognizing the need for unspecified
values within Value Types. It might also be nice for them to abide by
the WSDL/XML Schema standard for 'nillable="true"' within a type.

Thanks for your help.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3

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

Similar topics

0
by: Nick Caldwell | last post by:
Y'all, Problem: Reading complex data types returned from WSDL I'll present this in 3 sections. 1. Output of WSDL parser on Google API 2. Output of WSDL parser on Custom API 3. WSDL parser...
1
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i...
2
by: Erik Klein | last post by:
I have a WebService whose WSDL contains the following snippet: <complexType abstract="true" name="Type"> <sequence> <element name="localId" nillable="true" type="xsd:string"/> <element...
2
by: pshvarts | last post by:
(I'm new in SOAP) I get some wsdl file (from apache service ). I tried creating SOAP client with .NET - trying to add Web Reference and get error like: "Custom tool error: Unable to import...
0
by: Elhanan | last post by:
hi.. i have a small Web Service which is consumed by dotnet application the webservice is located in 2 places. the first is my local tomcat, and the second is in websphere server. problems is...
0
by: Andreas | last post by:
Hi, Im trying to consume a webservice described by the WSDL below, however When i try to add the WSDL it does not work, tried to run it through WSDL.EXE It validates in XMLSpy, but WSDL.exe...
1
by: Vishuonline | last post by:
Guys, I have had some experience in working with webservices created in .NET but this is the first time I am trying out one made in Java. When I run the wsdl exe to create a proxy class for...
0
by: robert | last post by:
Hi all, I'm having a hard time resolving a namespace issue in my wsdl. Here's an element that explains my question, with the full wsdl below: <definitions name="MaragatoService"...
9
by: Cesar | last post by:
Hello there, A java programmer sent me a wsdl file, which I have to use to consume his web methods. When I run the wsld.exe tool to generate the class' code, I get the following message: ...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.