Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ns1:myWCFCall
- xmlns:ns1="testNameSpace1"
- >
- <ns1:firstParam>
- <ns1:a></ns1:a>
- <ns1:b></ns1:b>
- </ns1:firstParam>
- <ns2:secondParam
- xmlns:ns2="testNameSpace2">
- <ns2:a></ns2:a>
- <ns2:a></ns2:a>
- </ns2:secondParam>
- </ns1:myWCFCall>
- [ServiceContract(Namespace = "testNameSpace1")]
- [XmlSerializerFormat]
- public interface ITestService
- {
- [OperationContract]
- myResponseObject myWCFCall(
- [XmlElement(Namespace = "testNameSpace1")] myObject firstParam,
- [XmlElement(Namespace = "testNameSpace2")] myOtherObject secondParam);
- }
- //Implementation
- public class Service1 : IService1
- {
- public myResponseObject myWCFCall(
- [XmlElement(Namespace = "testNameSpace1")] myObject firstParam,
- [XmlElement(Namespace = "testNameSpace2")] myOtherObject secondParam)
- {
- return new myResponseObject();
- }
- }
- //Sample classes
- [Serializable]
- public class myObject
- {
- [XmlElement]
- public string a;
- [XmlElement]
- public string b;
- }
- //tried putting this in another C# namespace, no difference in the results.
- [Serializable]
- public class myOtherObject
- {
- [XmlElement]
- public string a;
- [XmlElement]
- public string b;
- }
- <ns1:myWCFCall
- xmlns:ns1="testNameSpace1"
- >
- <ns1:firstParam>
- <ns1:a></ns1:a>
- <ns1:b></ns1:b>
- </ns1:firstParam>
- <ns1:secondParam
- xmlns:ns2="testNameSpace2">
- <ns2:a></ns2:a>
- <ns2:a></ns2:a>
- </ns1:secondParam>
- </ns1:myWCFCall>
- public class TheFirst
- {
- [MessageBodyMember]
- public string AOfTheFirst { get; set; }
- [MessageBodyMember]
- public string BOfTheFirst { get; set; }
- }
- public class TheSecond
- {
- [MessageBodyMember]
- public string AOfTheFirst { get; set; }
- [MessageBodyMember]
- public string BOfTheFirst { get; set; }
- }
- [MessageContract(IsWrapped = false)] //IsWrapped= "false" removes the OuterClasselement in the request element
- public class OuterClass{
- [MessageBodyMember(Namespace ="www.thefirst.com",Name ="aliasForFirst")]
- public TheFirst TheFirst { get; set; }
- [MessageBodyMember(Namespace ="www.thesecond.com",Name ="aliasForSecond")]
- public TheSecond TheSecond { get; set; }
- }
- [ServiceContract]
- public interface IXmlSerService
- {
- [OperationContract]
- OuterClass wcfCll(OuterClass outerClass);
- }
- public class XmlSerService:IXmlSerService
- {
- public OuterClass wcfCll(OuterClass outerClass)
- {
- return new OuterClass { TheFirst = new TheFirst { AOfTheFirst = "a", BOfTheFirst = "b" },TheSecond = new TheSecond { AOfTheFirst = "a", BOfTheFirst = "b" } };
- }
- }
Add Comment
Please, Sign In to add comment