I need to consume web service in C# website application. I generated the proxy class using wsdl command and I am able to use it to invoke the webservice and get the result.
The issue is that I have 2 fields in response xml which provide data in cdata tags. The values for these 2 fields are returned as empty strings. I tried to add the XMLText attribute to the field definition in the proxy as shown below.
[XmlText]
public string Title {
get {
return this.TitleField;
}
set {
this.TitleField = value;
}
}
[XmlText]
public string Description {
get {
return this.descriptionField;
}
set {
this.descriptionField = value;
}
}
but I am getting the following error when the above code change is done:
Exception Details: System.InvalidOperationException: Cannot serialize object of type 'WService.XXXXXXXXXX' because it has multiple XmlText attributes. Consider using an array of strings with XmlTextAttribute for serialization of a mixed complex type.
Here is how the values appear in the response: <Title><![CDATA[test title]]></Title> <Description><![CDATA[test description ]]></Description>
The datatype for both these elements is specified as string in the XSD. Please let me know how this issue needs to be fixed.