I have a WCF server which has a call having 2 parameters, but which require a different namespace for each parameter. I can't seem to specify the namespace for the parameters.
So the call which is sent to the server (which I cannot adapt):
<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>
I created a interface + implementation. I need to use XMLSerialization due to some other limitations of the standard serializer. Specifying XMLElement on parameter level (including the namespace) doesn't seem to work at all.
[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;
}
Adding [XmlRoot(Namespace = "testNameSpace2")] doesn't work for the first level. Only for sub-sequent levels (a, b)
So I keep getting the wrong result when I check the WSDL... (ns1:secondParam instead of ns2:secondParam):
<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>
Help.