@@ -4010,6 +4010,20 @@ public static void XmlMembersMapping_Soap_SimpleType()
40104010 Assert . Equal ( getDataRequestBodyValue . value , getDataRequestBodyActual . value ) ;
40114011 }
40124012
4013+ [ Fact ]
4014+ [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework , "dotnet/corefx #18964" ) ]
4015+ public static void XmlMembersMapping_Soap_CompositeType ( )
4016+ {
4017+ string memberName = "GetDataUsingDataContract" ;
4018+ var requestBodyValue = new CompositeTypeForXmlMembersMapping ( ) { BoolValue = true , StringValue = "foo" } ;
4019+ var requestBodyActual = RoundTripWithXmlMembersMappingSoap < CompositeTypeForXmlMembersMapping > ( requestBodyValue , memberName ,
4020+ "<?xml version=\" 1.0\" ?>\r \n <q1:CompositeTypeForXmlMembersMapping xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\" http://www.w3.org/2001/XMLSchema\" id=\" id1\" xmlns:q1=\" http://tempuri.org/\" >\r \n <BoolValue xsi:type=\" xsd:boolean\" >true</BoolValue>\r \n <StringValue xsi:type=\" xsd:string\" >foo</StringValue>\r \n </q1:CompositeTypeForXmlMembersMapping>" ) ;
4021+
4022+ Assert . NotNull ( requestBodyActual ) ;
4023+ Assert . Equal ( requestBodyValue . BoolValue , requestBodyActual . BoolValue ) ;
4024+ Assert . Equal ( requestBodyValue . StringValue , requestBodyActual . StringValue ) ;
4025+ }
4026+
40134027 [ Fact ]
40144028 public static void XmlMembersMapping_Soap_PrimitiveValue_HasWrapperElement ( )
40154029 {
@@ -4232,6 +4246,74 @@ public static void Xml_Soap_TypeWithReadOnlyMyCollectionProperty()
42324246 Assert . True ( value . Collection . SequenceEqual ( actual . Collection ) ) ;
42334247 }
42344248
4249+ [ Fact ]
4250+ [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework , "dotnet/corefx #18964" ) ]
4251+ public static void XmlMembersMapping_Soap_SoapComplexType ( )
4252+ {
4253+ string memberName = "EchoComositeTypeXmlSerializerFormatSoapResult" ;
4254+ var requestBodyValue = new SoapComplexType ( ) { BoolValue = true , StringValue = "hello" } ;
4255+
4256+ string baseline = "<root><q1:EchoComositeTypeXmlSerializerFormatSoapResponse xmlns:q1=\" http://tempuri.org/\" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\" http://www.w3.org/2001/XMLSchema\" ><EchoComositeTypeXmlSerializerFormatSoapResult href=\" #id1\" /></q1:EchoComositeTypeXmlSerializerFormatSoapResponse><q2:SoapComplexType id=\" id1\" a:type=\" q2:SoapComplexType\" xmlns:q2=\" http://tempuri.org/encoded\" xmlns:a=\" http://www.w3.org/2001/XMLSchema-instance\" ><BoolValue a:type=\" q3:boolean\" xmlns:q3=\" http://www.w3.org/2001/XMLSchema\" >true</BoolValue><StringValue a:type=\" q4:string\" xmlns:q4=\" http://www.w3.org/2001/XMLSchema\" >hello</StringValue></q2:SoapComplexType></root>" ;
4257+ string ns = s_defaultNs ;
4258+ string wrapperName = "EchoComositeTypeXmlSerializerFormatSoapResponse" ;
4259+
4260+ object [ ] value = new object [ ] { requestBodyValue } ;
4261+ XmlReflectionMember member = GetReflectionMember < SoapComplexType > ( memberName , ns ) ;
4262+ member . SoapAttributes . SoapElement = new SoapElementAttribute ( memberName ) ;
4263+ var members = new XmlReflectionMember [ ] { member } ;
4264+
4265+ var importer = new SoapReflectionImporter ( null , "http://tempuri.org/encoded" ) ;
4266+ var membersMapping = importer . ImportMembersMapping ( wrapperName , ns , members , hasWrapperElement : true , writeAccessors : true ) ;
4267+ var serializer = XmlSerializer . FromMappings ( new XmlMapping [ ] { membersMapping } ) [ 0 ] ;
4268+
4269+ object [ ] actual = SerializeAndDeserializeWithWrapper ( value , serializer , baseline ) ;
4270+ Assert . NotNull ( actual ) ;
4271+ Assert . Equal ( value . Length , actual . Length ) ;
4272+
4273+ var requestBodyActual = ( SoapComplexType ) actual [ 0 ] ;
4274+ Assert . NotNull ( requestBodyActual ) ;
4275+ Assert . Equal ( requestBodyValue . BoolValue , requestBodyActual . BoolValue ) ;
4276+ Assert . Equal ( requestBodyValue . StringValue , requestBodyActual . StringValue ) ;
4277+ }
4278+
4279+ [ Fact ]
4280+ [ SkipOnTargetFramework ( TargetFrameworkMonikers . NetFramework , "dotnet/corefx #18964" ) ]
4281+ public static void XmlMembersMapping_Soap_SoapComplexTypeWithArray ( )
4282+ {
4283+ string memberName = "EchoComositeTypeXmlSerializerFormatSoapResult" ;
4284+ var requestBodyValue = new SoapComplexTypeWithArray ( )
4285+ {
4286+ IntArray = new int [ ] { 1 , 2 } ,
4287+ StringArray = new string [ ] { "foo" , "bar" } ,
4288+ IntList = new List < int > ( ) { 1 , 2 } ,
4289+ StringList = new List < string > ( ) { "foo" , "bar" }
4290+ } ;
4291+
4292+ string baseline = "<root><q1:EchoComositeTypeXmlSerializerFormatSoapResponse xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\" http://www.w3.org/2001/XMLSchema\" xmlns:q1=\" http://tempuri.org/\" ><EchoComositeTypeXmlSerializerFormatSoapResult href=\" #id1\" /></q1:EchoComositeTypeXmlSerializerFormatSoapResponse><q2:SoapComplexTypeWithArray id=\" id1\" d2p1:type=\" q2:SoapComplexTypeWithArray\" xmlns:d2p1=\" http://www.w3.org/2001/XMLSchema-instance\" xmlns:q2=\" http://tempuri.org/encoded\" ><IntArray href=\" #id2\" /><StringArray href=\" #id3\" /><IntList href=\" #id4\" /><StringList href=\" #id5\" /></q2:SoapComplexTypeWithArray><q3:Array id=\" id2\" xmlns:q4=\" http://www.w3.org/2001/XMLSchema\" q3:arrayType=\" q4:int[2]\" xmlns:q3=\" http://schemas.xmlsoap.org/soap/encoding/\" ><Item>1</Item><Item>2</Item></q3:Array><q5:Array id=\" id3\" xmlns:q6=\" http://www.w3.org/2001/XMLSchema\" q5:arrayType=\" q6:string[2]\" xmlns:q5=\" http://schemas.xmlsoap.org/soap/encoding/\" ><Item>foo</Item><Item>bar</Item></q5:Array><q7:Array id=\" id4\" xmlns:q8=\" http://www.w3.org/2001/XMLSchema\" q7:arrayType=\" q8:int[2]\" xmlns:q7=\" http://schemas.xmlsoap.org/soap/encoding/\" ><Item>1</Item><Item>2</Item></q7:Array><q9:Array id=\" id5\" xmlns:q10=\" http://www.w3.org/2001/XMLSchema\" q9:arrayType=\" q10:string[2]\" xmlns:q9=\" http://schemas.xmlsoap.org/soap/encoding/\" ><Item>foo</Item><Item>bar</Item></q9:Array></root>" ;
4293+ string ns = s_defaultNs ;
4294+ string wrapperName = "EchoComositeTypeXmlSerializerFormatSoapResponse" ;
4295+
4296+ object [ ] value = new object [ ] { requestBodyValue } ;
4297+ XmlReflectionMember member = GetReflectionMember < SoapComplexTypeWithArray > ( memberName , ns ) ;
4298+ member . SoapAttributes . SoapElement = new SoapElementAttribute ( memberName ) ;
4299+ var members = new XmlReflectionMember [ ] { member } ;
4300+
4301+ var importer = new SoapReflectionImporter ( null , "http://tempuri.org/encoded" ) ;
4302+ var membersMapping = importer . ImportMembersMapping ( wrapperName , ns , members , hasWrapperElement : true , writeAccessors : true ) ;
4303+ var serializer = XmlSerializer . FromMappings ( new XmlMapping [ ] { membersMapping } ) [ 0 ] ;
4304+
4305+ object [ ] actual = SerializeAndDeserializeWithWrapper ( value , serializer , baseline ) ;
4306+ Assert . NotNull ( actual ) ;
4307+ Assert . Equal ( value . Length , actual . Length ) ;
4308+
4309+ var requestBodyActual = ( SoapComplexTypeWithArray ) actual [ 0 ] ;
4310+ Assert . NotNull ( requestBodyActual ) ;
4311+ Assert . True ( requestBodyValue . IntArray . SequenceEqual ( requestBodyActual . IntArray ) ) ;
4312+ Assert . True ( requestBodyValue . StringArray . SequenceEqual ( requestBodyActual . StringArray ) ) ;
4313+ Assert . True ( requestBodyValue . IntList . SequenceEqual ( requestBodyActual . IntList ) ) ;
4314+ Assert . True ( requestBodyValue . StringList . SequenceEqual ( requestBodyActual . StringList ) ) ;
4315+ }
4316+
42354317 [ Fact ]
42364318 public static void Xml_XmlTextAttributeTest ( )
42374319 {
0 commit comments