Guest User

Untitled

a guest
Jan 24th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. <ns1:myWCFCall
  2. xmlns:ns1="testNameSpace1"
  3. >
  4. <ns1:firstParam>
  5. <ns1:a></ns1:a>
  6. <ns1:b></ns1:b>
  7. </ns1:firstParam>
  8. <ns2:secondParam
  9. xmlns:ns2="testNameSpace2">
  10. <ns2:a></ns2:a>
  11. <ns2:a></ns2:a>
  12. </ns2:secondParam>
  13. </ns1:myWCFCall>
  14.  
  15. [ServiceContract(Namespace = "testNameSpace1")]
  16. [XmlSerializerFormat]
  17. public interface ITestService
  18. {
  19. [OperationContract]
  20. myResponseObject myWCFCall(
  21. [XmlElement(Namespace = "testNameSpace1")] myObject firstParam,
  22. [XmlElement(Namespace = "testNameSpace2")] myOtherObject secondParam);
  23. }
  24.  
  25. //Implementation
  26. public class Service1 : IService1
  27. {
  28.  
  29. public myResponseObject myWCFCall(
  30. [XmlElement(Namespace = "testNameSpace1")] myObject firstParam,
  31. [XmlElement(Namespace = "testNameSpace2")] myOtherObject secondParam)
  32. {
  33. return new myResponseObject();
  34. }
  35. }
  36.  
  37. //Sample classes
  38. [Serializable]
  39. public class myObject
  40. {
  41. [XmlElement]
  42. public string a;
  43. [XmlElement]
  44. public string b;
  45. }
  46.  
  47. //tried putting this in another C# namespace, no difference in the results.
  48. [Serializable]
  49. public class myOtherObject
  50. {
  51. [XmlElement]
  52. public string a;
  53. [XmlElement]
  54. public string b;
  55. }
  56.  
  57. <ns1:myWCFCall
  58. xmlns:ns1="testNameSpace1"
  59. >
  60. <ns1:firstParam>
  61. <ns1:a></ns1:a>
  62. <ns1:b></ns1:b>
  63. </ns1:firstParam>
  64. <ns1:secondParam
  65. xmlns:ns2="testNameSpace2">
  66. <ns2:a></ns2:a>
  67. <ns2:a></ns2:a>
  68. </ns1:secondParam>
  69. </ns1:myWCFCall>
  70.  
  71. public class TheFirst
  72. {
  73. [MessageBodyMember]
  74. public string AOfTheFirst { get; set; }
  75. [MessageBodyMember]
  76. public string BOfTheFirst { get; set; }
  77.  
  78. }
  79.  
  80. public class TheSecond
  81. {
  82. [MessageBodyMember]
  83. public string AOfTheFirst { get; set; }
  84. [MessageBodyMember]
  85. public string BOfTheFirst { get; set; }
  86.  
  87. }
  88.  
  89. [MessageContract(IsWrapped = false)] //IsWrapped= "false" removes the OuterClasselement in the request element
  90. public class OuterClass{
  91. [MessageBodyMember(Namespace ="www.thefirst.com",Name ="aliasForFirst")]
  92. public TheFirst TheFirst { get; set; }
  93. [MessageBodyMember(Namespace ="www.thesecond.com",Name ="aliasForSecond")]
  94. public TheSecond TheSecond { get; set; }
  95.  
  96.  
  97.  
  98.  
  99. }
  100.  
  101. [ServiceContract]
  102.  
  103. public interface IXmlSerService
  104. {
  105. [OperationContract]
  106.  
  107. OuterClass wcfCll(OuterClass outerClass);
  108. }
  109.  
  110. public class XmlSerService:IXmlSerService
  111. {
  112.  
  113.  
  114.  
  115. public OuterClass wcfCll(OuterClass outerClass)
  116. {
  117.  
  118. return new OuterClass { TheFirst = new TheFirst { AOfTheFirst = "a", BOfTheFirst = "b" },TheSecond = new TheSecond { AOfTheFirst = "a", BOfTheFirst = "b" } };
  119. }
  120.  
  121.  
  122. }
Add Comment
Please, Sign In to add comment