Reputation: 183
I am tasked with creating a WCF service operation that is going to transform XML from one form to another using XSLT. When doing this with plain old asmx Web Services I used an input parameter of type XmlDocument and a return type of the same.
The input XmlDocument needs to have an associated schema and namespace. In fact when our tester, tests this using SOAP UI against the asmx Web Service they get the following error -
Error: Type 'TXLife_Type' in namespace 'http://ACORD.org/Standards/Life/2' cannot be imported. Attributes must be optional and from namespace 'http://schemas.microsoft.com/2003/10/Serialization/'. Either change the schema so that the types can map to data contract types or use ImportXmlType or use a different serializer.
I am thinking that what I really need is 3 namespaces one for the ServiceContract one for the input XML parameter and one for the output XML being returned. How do I do this?
Upvotes: 0
Views: 283
Reputation: 183
For the service contract interface. I used this -
namespace MyNamespace
{
[ServiceContract(Namespace = "http://ItsAWonderfulLife.com/LifeSOA/Services/")]
public interface TX103toEAppXmlTransformServiceContract
{
[OperationContract, XmlSerializerFormat]
Output iGOTX103toLifeCommTest(Input input);
}
[MessageContract(WrapperNamespace = "http://ACORD.org/Standards/Life/2")]
public class Input
{
[MessageBodyMember]
public XElement TXLife { get; set; }
}
[MessageContract]
public class Output
{
[MessageBodyMember]
public XElement eAppXML { get; set; }
}
}
For the Service implementation -
[ServiceBehavior(Namespace = "http://ItsAWonderfulLife.com/LifeSOA/Services/")]
public class TX103toEAppXmlTransform : TX103toEAppXmlTransformServiceContract
{
...
}
Upvotes: 1