Bug 612 - Regression - 4.0.4 and later - WCF xml data retrieval
Summary: Regression - 4.0.4 and later - WCF xml data retrieval
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 4.x
Hardware: All All
: --- blocker
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Blocks: 667
  Show dependency tree
Reported: 2011-09-02 21:32 UTC by Wei-Yuen Tan
Modified: 2011-09-07 15:31 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

small WCF client that shows WCF regression in MT 4.0.4 and later (70.73 KB, application/zip)
2011-09-02 21:32 UTC, Wei-Yuen Tan

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Wei-Yuen Tan 2011-09-02 21:32:28 UTC
Created attachment 246 [details]
small WCF client that shows WCF regression in MT 4.0.4 and later

Possible duplicate - http://bugzilla.xamarin.com/show_bug.cgi?id=607 - sorry I am not savvy enough to know if this is the same bug.

Anyway I am building a client app for a major product by my company (http://www.meridiansystems.com/products/prolog/construction-project-management.asp - tens of thousands of users installed base), which has an API exposed via WSE3/WCF (interoperable).

Attached is sample code that demonstrates the issue.  It calls a WCF method that returns an XML document.  Works fine in MT 4.0.3, doesn't work at all in versions 4.0.4 to 4.0.7.

Comment 1 Sebastien Pouliot 2011-09-05 16:23:46 UTC
It could be related to #607 but it's not identical. 4.1.x+ do provide DataContractSerializerOperationBehavior and still fail your test case.

I do get a NullReferenceException using your sample, is that what you get ? 

Could you attach your failure to this bug report so we can ensure we're working on the right issue(s) ?

Comment 2 Sebastien Pouliot 2011-09-05 19:22:17 UTC
The NRE I'm getting comes from:

Exception in async operation: System.NullReferenceException: Object reference not set to an instance of an object
  at System.Xml.Serialization.XmlAttributes..ctor (ICustomAttributeProvider provider) [0x00032] in /Developer/MonoTouch/Source/mono/mcs/class/System.XML/System.Xml.Serialization/XmlAttributes.cs:64 
  at System.ServiceModel.Dispatcher.XmlMessagesFormatter.CreateReflectionMember (System.ServiceModel.Description.MessagePartDescription partDesc, Boolean isReturnValue) [0x00025] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs:68 
  at System.ServiceModel.Dispatcher.XmlMessagesFormatter.GetSerializer (System.ServiceModel.Description.MessageBodyDescription desc) [0x0007e] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs:106 
  at System.ServiceModel.Dispatcher.XmlMessagesFormatter.PartsToMessage (System.ServiceModel.Description.MessageDescription md, System.ServiceModel.Channels.MessageVersion version, System.String action, System.Object[] parts) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs:75 
  at System.ServiceModel.Dispatcher.BaseMessagesFormatter.SerializeRequest (System.ServiceModel.Channels.MessageVersion version, System.Object[] parameters) [0x000d4] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:192 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.CreateRequest (System.ServiceModel.Dispatcher.ClientOperation op, System.Object[] parameters) [0x0001e] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:618 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x0002d] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:516 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:486 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:466 

which is fairly new (coming from pull request #145)


Atsushi, can we change that line to deal with a null value ? e.g.

			m.XmlAttributes = partDesc.MemberInfo == null ? new XmlAttributes () : new XmlAttributes (partDesc.MemberInfo);

seems to "works for me"(tm). thanks!
Comment 3 Sebastien Pouliot 2011-09-07 14:16:39 UTC
Fixed in master, mono-2-10, mobile-master and monotouch-4.2 branches.
Comment 4 Wei-Yuen Tan 2011-09-07 14:45:50 UTC
Hi, I am just getting back to this after the Labour Day long weekend, I will go into more detail later today about the behaviour you should / shouldn't see, but to ensure that the bug is fully fixed, line 73 of Main.Monotouch.cs in the test case...


...should yield the following text in the Application Output: 

   Begin clearing and grubbing the site in preparation for excavation soon
Comment 5 Wei-Yuen Tan 2011-09-07 15:15:14 UTC
So, Sebastien, to answer your original question, a null reference error is indeed what I get.  And the cause is line 68 of Main.MonoTouch.cs...

   XmlReader xmlReader = new XmlNodeReader(pDoc.Any);

Let's back up a bit.  After doing all the handshake / setup stuff, and drilling down through a few wrappers, what my test program does is call the web service method ReadDocumentAsync().

The result is stored in ReadDocumentCompletedEventArgs.Result, and the completion event is raised.  Result is of proprietary type PrologDocument, and contains a member Any representing the XML Any element.

The problem in 4.0.4 and onwards was that the Any element was null, it should in fact contain a large, complex XML document representing all the business data returned by Prolog.

The remaining code in the test program deserializes the XML document (using a class generated from the original XSD) and spits out one of its fields to the console.
Comment 6 Sebastien Pouliot 2011-09-07 15:25:00 UTC
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/Mono.Security.dll [External]
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/System.dll [External]
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/monotouch.dll [External]
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/System.Xml.dll [External]
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/System.Core.dll [External]
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/System.Runtime.Serialization.dll [External]
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/System.ServiceModel.dll [External]
Loaded assembly: /private/var/mobile/Applications/D57ACE12-AEB9-407C-812E-A07531668E22/PrologWCF.Monotouch.app/MonoTouchDebug.exe
Thread started: Finalizer
Resolved pending breakpoint at '/Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs:69' to XmlReflectionMember System.ServiceModel.Dispatcher.XmlMessagesFormatter:CreateReflectionMember () [0x00025].
Thread started: 
Thread started: 
Thread started: 
Thread started: 
Thread started: 
Thread started: 
Began clearing and grubbing the site in preparation for excavation soon.

^^^ :-)
Comment 7 Wei-Yuen Tan 2011-09-07 15:31:00 UTC