Bug 41 - Webservice call always returning null
Summary: Webservice call always returning null
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 4.x
Hardware: Macintosh Mac OS
: High normal
Target Milestone: Untriaged
Assignee: Lluis Sanchez
Depends on:
Reported: 2011-07-22 04:33 UTC by F Hoogeboom
Modified: 2011-12-07 10:33 UTC (History)
5 users (show)

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

Testproject Webservice call (4.26 MB, application/x-zip-compressed)
2011-07-26 03:47 UTC, F Hoogeboom
Working dealerinfo in C# VS2010 (Win) (65.54 KB, application/x-zip-compressed)
2011-07-28 08:35 UTC, F Hoogeboom
Sample test case (53.80 KB, application/x-zip-compressed)
2011-10-05 19:11 UTC, Miguel de Icaza [MSFT]
self-contained sample ConsoleApplication2 (48.77 KB, application/octet-stream)
2011-10-06 03:11 UTC, F Hoogeboom
Screenshot successful webservice call (80.69 KB, image/png)
2011-10-06 04:31 UTC, F Hoogeboom
The ZIP version (54.45 KB, application/x-zip-compressed)
2011-10-07 02:38 UTC, F Hoogeboom

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 F Hoogeboom 2011-07-22 04:33:52 UTC
I’m VB.NET / C# / Java developer at the Accell Group in the Netherlands; we want to start building iPhone/iPad apps with MonoTouch so I bought an MacBook and downloaded the trial version of MonoTouch. Now I am building a small app to test communication with .NET webservices. When this works I get green light from the direction to buy licences.
We have a IBM iSeries server with WebSphere where we build our Java web services. We are already using web services with our Windows Mobile apps for a couple of years without any problems.
When I call those webservice with MonoTouch I always get NULL objects, I think something is going wrong in Mono but I need some help from a developer to solve this problem.

Attached you find a small project, the company code must be ACC1 in any way because otherwise our IBM server cant set the correct libraries.

with any value in the two fields there must be a response from the web-service. In VS2010 anything works perfect.
Maybe Im doing something wrong but any help would be appreciated.

Thanks in advance, Floris Hoogeboom
Comment 1 Atsushi Eno 2011-07-22 11:49:01 UTC
Probably you forgot the attachment?
Comment 2 F Hoogeboom 2011-07-25 03:01:30 UTC

I send the following email to your colleage Joseph Hill:

Ok, i tried again from my Windows machine.

Now I received the following error:

The file you are trying to attach is 4361 kilobytes (KB) in size. Attachments cannot be more than 1000 KB. 
We recommend that you store your attachment elsewhere and then insert the URL to it in a comment, or in the URL field for this bug. 
Alternately, if your attachment is an image, you could convert it to a compressible format like JPG or PNG and try again.

I cant make the project smaller. 

What can I do?

Thanks in advance.

(In reply to comment #1)
> Probably you forgot the attachment?
Comment 3 Admin 2011-07-25 14:28:18 UTC
The attachment limit has been raised, so adding the attachment should now work fine.
Comment 4 F Hoogeboom 2011-07-26 03:47:49 UTC
Created attachment 14 [details]
Testproject Webservice call
Comment 5 Atsushi Eno 2011-07-26 12:28:17 UTC
The repro is actually very simple and good (you just didn't have to include all those bin files and .app :) , But when I tried to access to the service on .NET 4.0, it returned WebException:

Unhandled Exception: System.Net.WebException: The operation has timed out
   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequ
est request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodN
ame, Object[] parameters)
   at TestProjectDeaklerinfo.DealerInfo.WSVDealerInfoServicesService.wsvdealerin
fo(WSVDealerInfoInput inputData)
   at TestProjectDeaklerinfo.Tset.Main()


Here is the console (non-MT) test that I ran on .NET 4 (almost the same as your repro):

using System;
using System.Collections.Generic;
using System.Linq;
using TestProjectDeaklerinfo.DealerInfo;
using System.Web.Services;

namespace TestProjectDeaklerinfo

public class Tset
	public static void Main ()
		Console.WriteLine (GetDealerInfo ("12345", "ABCDE", "ZZZZZ"));

	static string GetDealerInfo(string bedrijfscode, string dealercode, string wachtwoord)
		DealerInfo.WSVDealerInfoServicesService webservice = new WSVDealerInfoServicesService();
		DealerInfo.WSVDealerInfoInput webservice_i = new DealerInfo.WSVDealerInfoInput();
		webservice_i.WSVBedrijfscode = bedrijfscode;
		webservice_i.WSVDealercode = dealercode;
		webservice_i.WSVWachtwoord = wachtwoord;
		DealerInfo.WSVDealerInfoResult webservice_r = new WSVDealerInfoResult();
		webservice_r = webservice.wsvdealerinfo(webservice_i);
		return webservice_r.WSVDealerinfo + webservice_r.WSVFoutmelding;



Is the service down, or do I need specific input strings to get expected result?
Comment 6 F Hoogeboom 2011-07-27 03:06:38 UTC
Ok, sorry for that..

The reason why you have the timeout is because the field "bedrijfscode" must be "ACC1". (Was already in the bug report but I used the English translation for bedrijfscode)

The reason for that is that the IBM server we use needs a code to set a specific library.

I will post sample input and result within a few minutes.
Comment 7 F Hoogeboom 2011-07-27 04:46:36 UTC
I made a small windows VS2010 form application to test.

My mistake the first field "bedrijfscode" must be "1" instead of "ACC1", thats wy the webservice stopped.


Bedrijfscode = "1"
Dealercode = "test"
Wachtwoord = "123"

response must be:

ASSIGN1^Afspraak afname Sparta^        150^C;AFZ1^Afname voor afspraak^        107^C;                

My test program in VS2010:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dealerinfo.wsvDealerinfo;

namespace Dealerinfo
    public partial class Form1 : Form
        public Form1()

        private void button1_Click(object sender, EventArgs e)
            WSVDealerInfoServicesClient webservice = new WSVDealerInfoServicesClient();
            WSVDealerInfoInput webservice_i = new WSVDealerInfoInput();

            webservice_i.WSVBedrijfscode = "1";
            webservice_i.WSVDealercode = dealercode1.Text;
            webservice_i.WSVWachtwoord = wachtwoord.Text;

            WSVDealerInfoResult webservice_r = new WSVDealerInfoResult();

            webservice_r = webservice.wsvdealerinfo(webservice_i);

            result.Text = webservice_r.WSVDealerinfo.ToString() + webservice_r.WSVFoutmelding.ToString();   
Comment 8 Atsushi Eno 2011-07-27 09:22:32 UTC
OK now it does not timeout anymore, but it returns null response even on .NET (and NullReferenceException occurs).
Comment 9 F Hoogeboom 2011-07-27 09:26:22 UTC
Ok, that’s exactly the message I received. When I use this webservice/WSDL in Java/VB.NET/C# or C++ I have no troubles at all.

(You can try the code above in Visual Studio and you will see it works fine)

FYI: The WSDL and webservice are generated by IBM WebSphere
Comment 10 Atsushi Eno 2011-07-27 11:25:07 UTC
I don't understand your last message, so I'll give some questions to make situation clear:

- What is "exactly the message" ? I understand this as null reply object.
- What do you mean by "it works fine" ? If I understand correctly, null is the expected message and the NullReferenceException is how it "works".
- If all above are exactly I think (as described above), what is the problem after all?

If you mean, .NET does *not* return null, then no, I cannot reproduce such result. .NET *does* return null. If it doesn't for you, maybe your inputs to the web service is not what you gave in comment #7. Note that your sample code there does not give exact input (and actually it cannot be compiled because of insufficient code lines).
Comment 11 F Hoogeboom 2011-07-28 04:05:13 UTC
Sorry for the confusion (and my bad english), it returns a null reply object and not a message.
With "it works fine" i mean that I dont receive an null object in other development tools but a object with two string fields. The result of input in comment #7 is -> ASSIGN1^Afspraak afname Sparta^        150^C;AFZ1^Afname voor afspraak^       

So, the problem is in other development tools I get a filled string as reply and with monotouch I receive a null reply.

I can send you the same test project in VS2010 so you can see the difference in result.

I hope I made the problem clear.

Thanks in advance.
Comment 12 Atsushi Eno 2011-07-28 08:26:41 UTC
Hmm, then, the problem is that it likely returns non-null ("expected") result to you but it doesn't for me. Are the input "1", "test", "123" (as shown in comment #7) really correct?

Note that I'm entirely talking about the results on Microsoft .NET since comment #8 (i.e. there is only "other development tool" which is .NET Framework). It is not about mono behavior, but the difference between your results on .NET and my results on .NET, of your code.

For reference, this is the exact code I compiled (with Web Reference/DealerInfo/Reference.cs) and ran. There is no ambiguous point for input values. This must be based on the code on comment #7.

using System;
using System.Collections.Generic;
using System.Linq;
using TestProjectDeaklerinfo.DealerInfo;
using System.Web.Services;

namespace TestProjectDeaklerinfo

public class Tset
        public static void Main ()
                Console.WriteLine (GetDealerInfo ("1", "test", "123"));

        static string GetDealerInfo(string bedrijfscode, string dealercode, string wachtwoord)
                DealerInfo.WSVDealerInfoServicesService webservice = new WSVDealerInfoServicesService();
                DealerInfo.WSVDealerInfoInput webservice_i = new DealerInfo.WSVDealerInfoInput();

                webservice_i.WSVBedrijfscode = bedrijfscode;
                webservice_i.WSVDealercode = dealercode;
                webservice_i.WSVWachtwoord = wachtwoord;

                DealerInfo.WSVDealerInfoResult webservice_r = new WSVDealerInfoResult();
                webservice_r = webservice.wsvdealerinfo(webservice_i);
                if (webservice_r == null)
                        return "(null)";

                return webservice_r.WSVDealerinfo + webservice_r.WSVFoutmelding;


Comment 13 F Hoogeboom 2011-07-28 08:35:20 UTC
Created attachment 31 [details]
Working dealerinfo in C# VS2010 (Win)

This is an working example of the same code in VS2010 on my windows machine.
Comment 14 F Hoogeboom 2011-07-28 08:39:43 UTC
Strange, the input is correct. You can try in the VS project I attached.

I dont really understand how its possible you dont get the response in Microsoft .NET

Our webservices are used from differend platforms and tools (fe Java and PHP) and I never had this problem before. Maybe this is MAC related?
Do you work with with MAC or Windows?

Thanks in advance.
Comment 15 Atsushi Eno 2011-07-28 08:43:44 UTC
Oh... your first example in the attachment is all about Web Reference which is System.Web.Services. The next sample at comment #13 is about Service Reference which is *WCF*. They are totally different beast.

Anyways now I could reproduce the issue, so I can investigate the actual issue.
Comment 16 F Hoogeboom 2011-07-28 10:49:10 UTC
Ok, sorry for the confusion. 

I hope you can find the problem.

Thanks in advance.
Comment 17 F Hoogeboom 2011-07-29 05:23:01 UTC
FYI I am out of the office until 15 august for a short holiday. I will read my mail on a regular base.
Comment 18 Atsushi Eno 2011-08-03 22:14:23 UTC
These days I have been trying my fix in mono master, but it seems the server is down. please let me know if it's back and I'll try it again.
Comment 19 F Hoogeboom 2011-08-05 03:27:40 UTC
I think you did the test during the nightwork (databasemaintanance) of our iSeries.
The nightwork starts at 2.00 until approx 5.00 (Amsterdam timezone).
The webservice is running correctly at this moment. Thanks in advance.
Comment 20 Atsushi Eno 2011-08-05 05:05:38 UTC
OK, thanks. Now I verified my fix actually fixed this issue. It will be included when MonoTouch release is based on the mono revisions after my fix (0c7d5fcc in master or 0a7f80fb in mono-2-10).
Comment 21 F Hoogeboom 2011-08-05 06:28:14 UTC
Ok, thanks a lot! Any idea when the fix will be released?
Whas it a serializing problem?
Comment 22 Atsushi Eno 2011-08-05 06:52:19 UTC
The former releases [*1] may give us wild guess, but since our organization changed, it is now hard to foretell when the new release comes out...

The problem was about MessageParameterAttribute handling which seemed minor feature and unsupported until these days.

[*1] http://ios.xamarin.com/Releases
Comment 23 Miguel de Icaza [MSFT] 2011-08-05 11:14:07 UTC
Our plan is about a week or two from now.
Comment 24 F Hoogeboom 2011-09-28 14:40:32 UTC
Now Im testing the project I attached to Bug 41 again but still have the same error, can you tell me what I should do to get the webservice working? 

Maybe you can send me the project that worked when you validated the fix of bug 41.

Im now on:

Monodevelop 2.8 Beta 2 (2.7.21)
Mono 2.10.5
GTK 2.24.5
Monotouch 4.2 Evaluation
Comment 25 F Hoogeboom 2011-09-28 14:53:36 UTC
Response from Miguel de Icaza:
I looked at the two attachments that you shared with us.

Response from Floris Hoogeboom:
The first one works as intended (it returns null on both MonoTouch and .NET).   The second one is a Forms application for .NET 4.0 and I could not get it to run on MonoTouch.
The First one should not return null, that’s the problem. The second Form applications shows the correct result.
This is the used WSDL:

Because you cant run the Forms application I provided a online test client where you can check the result:

Choose: wsvdealerinfo(nl.accell.accentry.programcallbean.WSVDealerInfoInput)  and make sure to fill in the fields as below:

The result is:

ASSIGN1^Afspraak afname Sparta^ 0^C;AFZ1^Afname voor afspraak^ 7^C;^Totaal in order^ 0^C;^Afname Merk fiets^ 0^C;AFZ7^Afname Electrisch^ 7^C;AFZ5V^Afname Merk vorig seizoen^ 12^C;AFZ7V^Afname Elec vorig seizoen^ 26^C;
Gebruikerscode onbekend
Now the question is, how to get this result in MonoTouch.
Now the result in monotouch is null (nullreference).
 Response from Miguel de Icaza:
Notice that the first one uses the old System.Web.Services stack, while the second one uses the new WCF stack.
Response from Floris Hoogeboom:
I know, I tried both but no positive result.
Response from Miguel de Icaza:
Please provide a self-contained test case in MonoTouch that exhibits the problem.    

Response from Floris Hoogeboom:
I think you can use the attachments in this bug
Comment 26 Atsushi Eno 2011-09-28 22:28:15 UTC
Miguel, can you confirm that attachment?
Comment 27 F Hoogeboom 2011-10-03 10:10:12 UTC
Hello Guys, I need to build a demo app before the end of this month.
I hope you have a solution by then.

Thanks in advance.
Comment 28 Chris Hardy [MSFT] 2011-10-03 19:19:11 UTC
Hi F Hoogeboom,

I have created this sample from your MonoTouch project: 


This does not work on either Mono or within VS2010.

The problem that I can see is that the example above that doesn't work on either platform uses the first line as follows;
WSVDealerInfoServicesService webservice = new WSVDealerInfoServicesService();

where as the working VS2010 project you send across has this as the first line;

WSVDealerInfoServicesClient webservice = new WSVDealerInfoServicesClient();

So we'll need a MonoTouch project that's using WSVDealerInfoServicesClient that doesn't work to be able to look into this issue.

Hope this helps,

Chris Hardy
Comment 29 F Hoogeboom 2011-10-04 08:00:01 UTC
Hello Chris,

I changed your example so it works, importend is the input, the "bedrijfscode" sets the correct librylist on our AS400 with wrong input the web service wont give a response.

using System;
using ConsoleDealerinfo.wsvDealerInfo;

namespace ConsoleDealerinfo
    class Program
        public static void Main(string[] args)
            Console.WriteLine("Hello World!");
            var response = GetDealerInfo("1", "Test", "123");

        private static string GetDealerInfo(string bedrijfscode, string dealercode, string wachtwoord)

            WSVDealerInfoServicesClient webservice = new WSVDealerInfoServicesClient();

            WSVDealerInfoInput webservice_i = new WSVDealerInfoInput();

            webservice_i.WSVBedrijfscode = bedrijfscode;
            webservice_i.WSVDealercode = dealercode;
            webservice_i.WSVWachtwoord = wachtwoord;

            WSVDealerInfoResult webservice_r = new WSVDealerInfoResult();
            webservice_r = webservice.wsvdealerinfo(webservice_i);

            return webservice_r.WSVDealerinfo + webservice_r.WSVFoutmelding;
Comment 30 F Hoogeboom 2011-10-04 08:29:03 UTC
Ok, now im trying to make a monotouch project example with WSVDealerInfoServicesClient.

For some reason my monotouch autocomplete is broken but..... within monotouch I only have the WSVDealerInfoServicesService available (using .net 2.0 WebServices).
So I cant make an example with WSVDealerInfoServicesClient within Monotouch.

(I also tried to add the reference as WCF, but that wont work.) 

So my problem is I cant get this simple webservice running in Monotouch (2.0 Webservice or WCF) This webservices works in all other languages and develop tools.

How would you use this webservice within monotouch?
Comment 33 Miguel de Icaza [MSFT] 2011-10-05 19:11:10 UTC
Created attachment 614 [details]
Sample test case
Comment 34 Miguel de Icaza [MSFT] 2011-10-05 19:11:53 UTC
The above sample test case was created on Windows, and it fails to run against your server with the same Nullreference exception, this time it is a Java exception on your server side.

Please upload a self-contained sample that shows this working on Visual Studio 2010.
Comment 35 F Hoogeboom 2011-10-06 03:11:13 UTC
Created attachment 617 [details]
self-contained sample ConsoleApplication2
Comment 36 F Hoogeboom 2011-10-06 03:16:53 UTC
I added an attachment with you sample ConsoleApplication2.

I created an var R as WSVDealerInfoResult and I see the correct output without any problems. 

Can you tell me what the exact Java exception was? Only thing I can imagine is that you were testing during our nightwork (databasemaintanance) because of the time difference.

Thanks in advance.
Comment 37 F Hoogeboom 2011-10-06 04:31:50 UTC
Created attachment 619 [details]
Screenshot successful webservice call
Comment 38 Miguel de Icaza [MSFT] 2011-10-06 12:22:28 UTC
Can you please attach your sample as a ZIP file?
Comment 41 F Hoogeboom 2011-10-07 02:38:11 UTC
Created attachment 638 [details]
The ZIP version
Comment 42 Lluis Sanchez 2011-10-10 14:31:00 UTC
The problem is the Form property in the XmlElementAttribute attributes applied to class fields. .NET is setting Form=XmlSchemaForm.Unqualified by default to every field, while Mono is not setting that property.

I checked the behavior of XmlSchema, and both .NET and Mono return XmlSchemaForm.None in all schema elements for the web service schema. So XmlSchema is returning the correct value.

When generating code, looks like .NET is defaulting to XmlSchemaForm.Unqualified when it finds XmlSchemaForm.None, while Mono doesn't. This is easy to test by running the "xsd /c" command on a schema file like this:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema elementFormDefault="qualified" xmlns:intf="http://xamarin.com/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://programcallbean.accentry.accell.nl">
  <xsd:element name="dataElement">
	      <xsd:element name="data" type="xsd:string" />

.NET generates a class with a data field and it sets Form=XmlSchemaForm.Unqualified to it.

I'll try a patch to change this default, although I'm afraid of the effect that this change may have in all the web services that currently work. This will require some extensive testing.
Comment 43 Miguel de Icaza [MSFT] 2011-10-10 17:53:47 UTC
Lluis, could we add a flag that would activate this behavior?

We would have to ship I guess an updated Mono and an updated MonoDevelop (the UI bits that would enable this), is that correct?

Comment 44 F Hoogeboom 2011-10-11 08:28:42 UTC
If I can be at any help... for example testing a patch. No problem!
Comment 45 Lluis Sanchez 2011-10-26 05:41:21 UTC
I committed a fix in master and the 2.10 branch. After some more research, I think the fix is safe. It only affects to code generation, so applications already compiled and running can't be affected by a potential regression. I also ran our web service proxy generation test suite (which includes hundreds of wsdl files), and there wasn't any difference in the generated code.
Comment 46 F Hoogeboom 2011-10-28 08:35:58 UTC
Great! Any idea when the fix will be released?
Comment 47 F Hoogeboom 2011-12-01 10:12:16 UTC
Any news on this issue guys? When is the fix available and what is the correct procedure to import and use this WSDL?

Thanks in advance.
Comment 48 Miguel de Icaza [MSFT] 2011-12-01 21:56:27 UTC
The fix will come with our upcoming Mono release (it is a bug in our tools shipped with Mono, not a bug in MonoTouch).

We will have a beta on Tuesday.
Comment 49 F Hoogeboom 2011-12-04 13:21:03 UTC
Ok, can you tell me how to proceed after this update? Should I import the WSDL again?

Thanks in advance.
Comment 50 Lluis Sanchez 2011-12-06 03:26:44 UTC
Yes, after updating mono you'll have to import the WSDL again.
Comment 51 Miguel de Icaza [MSFT] 2011-12-06 16:57:15 UTC
Our new release of Mono (2.10.7) fixes this problem.

You need to install it from the Beta channel which you can select in the PReferences menu.
Comment 52 F Hoogeboom 2011-12-07 10:33:12 UTC
Ok, I can confirm that this fix is working.

Thanks a lot!