[System.Web.Services] Test Header sharing issue.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 30 Jun 2016 12:42:42 +0000 (13:42 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 30 Jun 2016 16:56:16 +0000 (17:56 +0100)
Covers #41564

When multiple methods shared soap header a duplicate key exception would
be thrown.

This issue only occurs on XAMMAC and MOBILE where the non reference
source serializer is still used.

mcs/class/System.Web.Services/Test/System.Web.Services.Protocols/SoapHttpClientProtocolTest.cs

index 0019e05c2788b0eb75309d07322d962e7dbfb84c..cd9dc050fe711beb2559a4254f0b7aff4425f7da 100755 (executable)
@@ -243,5 +243,44 @@ namespace MonoTests.System.Web.Services.Protocols
                                }
                        }
                }
+
+               public class RequestHeader : SoapHeader
+               {
+               }
+
+               public class ResponseHeader : SoapHeader
+               {
+               }
+
+               [WebServiceBindingAttribute(Name = "ServiceWithHeaders", Namespace = "https://example.com")]
+               public class ServiceWithHeaders : SoapHttpClientProtocol
+               {
+                       public RequestHeader RequestHeader { get; set; }
+                       public ResponseHeader ResponseHeader { get; set; }
+
+                       [SoapHeaderAttribute("ResponseHeader", Direction = SoapHeaderDirection.Out)]
+                       [SoapHeaderAttribute("RequestHeader")]
+                       [SoapDocumentMethodAttribute("", RequestNamespace = "https://example.com", ResponseNamespace = "https://example.com", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
+                       public int method1()
+                       {
+                               return 0;
+                       }
+
+                       [SoapHeaderAttribute("ResponseHeader", Direction = SoapHeaderDirection.Out)]
+                       [SoapHeaderAttribute("RequestHeader")]
+                       [SoapDocumentMethodAttribute("", RequestNamespace = "https://example.com", ResponseNamespace = "https://example.com", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
+                       public int method2()
+                       {
+                               return 0;
+                       }
+               }
+
+               [Test] // Covers #41564
+               public void ServiceWithHeader () {
+                       var service = new ServiceWithHeaders ();
+                       Assert.IsNotNull (service);
+                       // Should not throw an exception
+                       // XAMMAC specific bug
+               }
        }
 }