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.
Can you share the code for 'WService.XXXXXXXXXX' ? I need to see how you are populating the Title and Description properties and returning them from the web service.
Lou Prete [MSFT]
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Bhuvana.Indu...
0 Points
1 Post
Unable to read xml data present in webservice response using c# proxy class
Dec 09, 2012 10:42 AM|LINK
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.
lprete
Member
385 Points
57 Posts
Microsoft
Re: Unable to read xml data present in webservice response using c# proxy class
Dec 14, 2012 11:02 AM|LINK
Can you share the code for 'WService.XXXXXXXXXX' ? I need to see how you are populating the Title and Description properties and returning them from the web service.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.