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

Interop questions (nil/null value/reference)

I think I've figured out my interop problems, but I'd like some
confirmation that I'm not going down the wrong path.

I'm connecting to a web service over which I have no control, and it's
written in Java. My client is written in C#. Several of the WSDLs
use nil char, nil dateTime, nil decimal (that is, they all use
'nillable', they do not use occurs=0) for many of the response
variables. Therefore, I have to do something in my proxy class to
handle nil values, otherwise the XML deserializer chokes on the
'nil="true"' values that come back for such types.

It seems that I can modify the proxy class in one of these ways (or a
combo), depending on how I need to use the proxy class:

1. Change all the types in the proxy class for the corresponding XML
variables to "string," and handle any conversion appropriately after I
get the response back. That would mean, for example, that a variable
declared as Decimal in the proxy class would be changed (by hand) to
string, and then, when I wanted to use the variable, I would do
something like:

if ((null != ProxyObj.proxyVar) && ("" != ProxyObj.proxyVar))
System.Datetime myDateTimeOustideProxyClass =
Convert.ToDatetime(ProxyObj.proxyVar);
else
System.Datetime myDateTimeOustideProxyClass = Datetime.MinVal;

2. Use the technique described in:
http://blogs.msdn.com/smguest/archiv...07/128113.aspx
This article suggests creating a new class that shadows the value
types that cannot be nilable. Sort of a proxy class for the value
types in the proxy class.

My two questions:

1. Am I pointed anywhere near the right direction?

2. Is there an easier workaround for this?

3. Any ideas on automating (or at least easing the burden of)
manually modifying the proxy class whenever I generate a new one (or
refresh an existing one)?

Thanks.

Michael
Nov 23 '05 #1
4 1745
My humble opinion I think Simon has got it right I would go with his
last idea about using the complexType. Yes some work, but once it is
done, it's done.

Nov 23 '05 #2
Well , I agree with Simon's approach but i think it's too much for me.
Especially when it involves a complex schema, as most situation in
document based messaging. I would normally use the types (as defined in
the WSDL) and create C# objects using XSD.exe( Version 2.0 handels this
better with Nullable<type>) . The other way is using some sort of
mapping tool. In my case I use Altova XMLSpy to generate the codes.
which does a more complex and proper mapping than XSD.exe. which is
basically you manually control the soap object serialization.
regards
erymuzuan mustapa

Keenan Newton wrote:
My humble opinion I think Simon has got it right I would go with his
last idea about using the complexType. Yes some work, but once it is
done, it's done.

Nov 23 '05 #3
On 20 Feb 2005 13:12:46 -0800, "Keenan Newton" <ka*********@yahoo.com>
wrote:
My humble opinion I think Simon has got it right I would go with his
last idea about using the complexType. Yes some work, but once it is
done, it's done.


Okay, but you can do this only if you control the web service. I
don't, so I cannot change what the web service sends me.
Nov 23 '05 #4
This sample shows one approach to handling nillable types that correspond to
..NET Value types, on the client side.
http://cheeso.members.winisp.net/src...=XsiNilDate.cs

The sample is framed as an XML serialization app. To use it in a webservice
client, what you would do is modify the generated proxy so that instead of
returning TypeA, it returns your hand-coded TypeA_Memento thing (See the
example). It wouldn't be hard to parse a type, either in XSD or in C#, and
mechanize the production of the memento.

It does tend to complexify the programming model on the client side, of
course, because now ya gotstabe checkin all those value types to see if they
are valid or not before using them. Eh, that's the cost of doing business,
though, isn't it?

-D
<mf*******@RemoveThis.MJFlanagan.com> wrote in message
news:1k********************************@4ax.com...
On 20 Feb 2005 13:12:46 -0800, "Keenan Newton" <ka*********@yahoo.com>
wrote:
My humble opinion I think Simon has got it right I would go with his
last idea about using the complexType. Yes some work, but once it is
done, it's done.


Okay, but you can do this only if you control the web service. I
don't, so I cannot change what the web service sends me.

Nov 23 '05 #5

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

Similar topics

0
by: roy | last post by:
I try to call com written in VB 6.0. When I use VS.net Studio to do the debuging, some time it works fine, some time I got the following message: Server Error in '/GISOnlineReservation'...
0
by: roy | last post by:
I try to call com written in VB 6.0., some time it works fine, some time I got the following message: Server Error in '/GISOnlineReservation' Application....
2
by: Ross Micheals | last post by:
All I have some general .NET questions that I'm looking for some help with. Some of these questions (like the first) are ones that I've seen various conflicting information on, or questions that...
0
by: keefah | last post by:
Hi, I'm writing a C# web app that uses Outlook to send email. I use a reference to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I tracked down some stuff on the Net...
15
by: sandwich_eater | last post by:
I want to know how to set an std::list iterator variable to make it null or nil. If this is not possible what is the value of an uninitialised std::list iterator and is it ok to assign this value...
3
by: KillerJ | last post by:
I found a post about this exact issue: ...
2
by: JC | last post by:
Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error is a...
0
by: Tina | last post by:
I've gotten this before where it says there is a problem with Interop.MSDASC but I can't remember what causes this. This is a 1.1 app I'm trying to debug in vs2005. It was running yesterday just...
2
by: =?iso-8859-1?q?Norbert_P=FCrringer?= | last post by:
Hello there, I've got following serializable property: public string Field { get { return _fields; } set { _fields = value; } }
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?
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
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,...

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.