Bug 27251 - Web Service: XmlSerialization ignores XmlIgnoreAttribute and Specified
Summary: Web Service: XmlSerialization ignores XmlIgnoreAttribute and Specified
Status: CONFIRMED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 5.4 (2017-06)
Hardware: PC Windows
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-20 08:57 UTC by Stefan K
Modified: 2017-12-06 17:56 UTC (History)
5 users (show)

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


Attachments
WebserviceTest sample (66.91 KB, application/x-zip)
2015-02-20 08:58 UTC, Stefan K
Details


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 for Bug 27251 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Stefan K 2015-02-20 08:57:53 UTC
Android code:
=========================================
Service1 service = new Service1();
service.Url = @"http://10.0.1.127:8080/Service1.svc";
string s = service.GetData(50, false);
textView.Text = s;
=========================================
Desktop code:
=========================================
Service1 service = new Service1();
service.Url = @"http://10.0.1.127:8080/Service1.svc";
string s = service.GetData(50, false);
label1.Text = s;
=========================================
Android request:
=========================================
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetData xmlns="http://tempuri.org/">
      <valueSpecified>false</valueSpecified>
    </GetData>
  </soap:Body>
</soap:Envelope>
=========================================
Desktop request.
=========================================
<?xml version = "1.0" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetData xmlns="http://tempuri.org/" />
  </soap:Body>
</soap:Envelope>
=========================================

The problem seems to be, that the Android implementation generates "specified" fields for each primitive type. And the specified fields are passed in the request, where they should not exist at all. 

If pass complex objects to the webservice, the implementation works fine.

A WCF Service ignores the specified fields, so there is no problem with it on that side, but if you use it with Java EE SOAP Webservice it results in an error (UnmarshallingError).

I attached sample source code for you. I used Membrane SOAP Monitor to trace the client/server communication.

My guess is the problem is with the xml serializer, because the "specified" fields are marked with an XmlIgnoreAttribute in the generated code.

It seem to be related to this problem:
https://bugzilla.xamarin.com/show_bug.cgi?id=1852
Comment 1 Stefan K 2015-02-20 08:58:46 UTC
Created attachment 9942 [details]
WebserviceTest sample
Comment 2 John Miller [MSFT] 2017-12-05 21:32:16 UTC
Hi Stefan,

I saw your message on the forums about this issue and I was not able to run the projects yet. In the meantime, are you still able to reproduce the problem with the latest 15.5 release?
Comment 3 Stefan K 2017-12-05 22:02:00 UTC
I tryed it again in 15.4 and the problem isn't fixed there.
Comment 4 John Miller [MSFT] 2017-12-05 22:14:39 UTC
Hi Stefan,

I'll continue to work on reproducing this. I am curious if you can reproduce with 15.5. Thanks!
Comment 5 Stefan K 2017-12-05 23:43:54 UTC
Hi John,

i updated my VS version and can confirm, that the problem is still present in the 15.5 version and Xamarin Android 8.1.0.24.
Comment 6 Stefan K 2017-12-06 15:15:22 UTC
Hi John,

what's holding you back to reproduce the problem. Maybe I can help.
Comment 7 John Miller [MSFT] 2017-12-06 16:10:56 UTC
Hi Stefan,

I am having trouble getting an Android/iOS app to connect to the service. It might be related to my machines firewall which I cannot change. However, even localhost is not working. The WindowsTest project you included works OK, but the result I get back is "You entered: 0" which I am not sure is expected or not.
Comment 8 Stefan K 2017-12-06 16:50:51 UTC
Hi John,

I recorded a demonstration for you here:

https://youtu.be/17bNnDzs7sA
Comment 9 Stefan K 2017-12-06 17:05:34 UTC
> I get back is "You entered: 0" which I am not sure is expected or not.

If you want the result, you must call it like:

service.GetData(50, true);

Then you got:

Windows:

<?xml version = "1.0" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <GetData xmlns="http://tempuri.org/">
      <value>50</value>
    </GetData>
  </soap:Body>
</soap:Envelope>


Android:

<?xml version = "1.0" ?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetData xmlns="http://tempuri.org/">
      <value>50</value>
      <valueSpecified>true</valueSpecified>
    </GetData>
  </soap:Body>
</soap:Envelope>
Comment 10 John Miller [MSFT] 2017-12-06 17:56:11 UTC
I'm going to confirm based on the video provided in Comment #8. I'm not able to run the sample in my environment successfully but I believe that's an issue with my setup and not the sample.