This message was discovered on microsoft.public.dotnet.framework.adonet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Manuel |
| GOOD ANSWER |
Hi,
I want to send a DataSet containing a DataTable with an expression column via WebService. Seems like the (de-) serialization doesn't work, an exception "InvalidOperationException: There is an error in XML document" is thrown. Anybody any hints, tips or fixes?
Kind regards, Manuel
|
|
|
| |
|
|
| |
| |
| William Ryan eMVP (VIP) |
| GOOD ANSWER |
Can you show me what the XML looks like. in and of itself here's an example of the serialized data (I have the code that generated it below): <MyTable> <Department>899</Department> <Work_Type>4223</Work_Type> <Job_Number>8 12446CLXO4</Job_Number> <Report_File_Name>0716BRB.CN</Report_File_Name> <Merged_Doc_Name>Z:\Work\0716BRB.CN</Merged_Doc_Name> <Report_Type>NOT GIVEN</Report_Type> <Exp>113446CN4 4</Exp> </MyTable>
da.Fill(ds, "MyTable");
DataColumn dco = new DataColumn("Exp", System.Type.GetType("System.String"));
dco.Expression = "Job_Number + ' ' + Work_Type";
ds.Tables[0].Columns.Add(dco);
ds.WriteXml(@"C:\TestTest.xml");
If you could post the code you're using it would help out though and let me know which line ni the WS is having the problem.
--
W.G. Ryan, eMVP
Have an opinion on the effectiveness of Microsoft Embedded newsgroups? Let Microsoft know! https://www.windowsembeddedeval.com/community/newsgroups "Manuel" <Click here to reveal e-mail address> wrote in message news:05be01c46e3d$933aef30$Click here to reveal e-mail address... [Original message clipped]
|
|
|
| |
|
|
| |
| |
| Manuel Trunk |
| GOOD ANSWER |
Ok, here ist the schema of the dataset. The problem seems to be the relation in the expression column "EX".
<xs:schema id="DataSet1" targetNamespace="http://www.tempuri.org/DataSet1.xsd" xmlns:mstns="http://www.tempuri.org/DataSet1.xsd" xmlns="http://www.tempuri.org/DataSet1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="DataSet1" msdata:IsDataSet="true" msdata:Locale="de-CH"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="AIRPORT"> <xs:complexType> <xs:sequence> <xs:element name="CODE" type="xs:string" /> <xs:element name="LANGUAGE" type="xs:string" /> <xs:element name="NAME" type="xs:string" minOccurs="0" /> <xs:element name="SHORTNAME" type="xs:string" minOccurs="0" /> <xs:element name="COUNTRY" type="xs:string" minOccurs="0" /> <xs:element name="STATE" type="xs:string" minOccurs="0" /> <xs:element name="CITY" type="xs:string" minOccurs="0" /> <xs:element name="RAILSTATION" type="xs:decimal" minOccurs="0" /> <xs:element name="EX" msdata:ReadOnly="true" msdata:Expression="Parent.language_code" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="LANGUAGE_CODE"> <xs:complexType> <xs:sequence> <xs:element name="LANGUAGE_CODE" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> <xs:unique name="Constraint1" msdata:PrimaryKey="true"> <xs:selector xpath=".//mstns:AIRPORT" /> <xs:field xpath="mstns:CODE" /> <xs:field xpath="mstns:LANGUAGE" /> </xs:unique> <xs:unique name="LANGUAGE_CODE_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true"> <xs:selector xpath=".//mstns:LANGUAGE_CODE" /> <xs:field xpath="mstns:LANGUAGE_CODE" /> </xs:unique> <xs:keyref name="LANGUAGE_CODEAIRPORT" refer="LANGUAGE_CODE_Constraint1"> <xs:selector xpath=".//mstns:AIRPORT" /> <xs:field xpath="mstns:LANGUAGE" /> </xs:keyref> </xs:element> </xs:schema>
An example record passed by the Web Service looks like:
<AIRPORT diffgr:id="AIRPORT1" msdata:rowOrder="0"> <CODE>GEO</CODE> <LANGUAGE>EN</LANGUAGE> <NAME>Timehri Airport</NAME> <SHORTNAME>Timehri</SHORTNAME> <COUNTRY>GY</COUNTRY> <CITY>GEO</CITY> <RAILSTATION>0</RAILSTATION> <EX>EN</EX> </AIRPORT>
The exception thrown is: [IndexOutOfRangeException: Cannot find relation 0.] System.Data.DataTableRelationCollection.get_Item(Int32 index) System.Data.LookupNode.Bind(DataTable table, ArrayList list) System.Data.DataExpression.Bind(DataTable table) System.Data.DataExpression..ctor(String expression, DataTable table, Type type) System.Data.DataColumn.set_Expression(String value) System.Data.Merger.MergeSchema(DataTable table) System.Data.Merger.MergeTableData(DataTable src) System.Data.Merger.MergeDataSet(DataSet source) System.Data.DataSet.Merge(DataSet dataSet, Boolean preserveChanges, MissingSchemaAction missingSchemaAction)
TestDataSetColumnBug.localhost.DataSet1.ReadXmlSerializabl e(XmlReader reader) in c:\inetpub\wwwroot\TestDataSetColumnBug\Web References\localhost\Reference.cs:150
System.Data.DataSet.System.Xml.Serialization.IXmlSerializa ble.ReadXml(XmlReader reader)
System.Xml.Serialization.XmlSerializationReader.ReadSerial izable(IXmlSerializable serializable)
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializa tionReader1.Read3_HelloWorldResponse() +328
[InvalidOperationException: There is an error in XML document (1, 1204338).] System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader, String encodingStyle) System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader)
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadR esponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
System.Web.Services.Protocols.SoapHttpClientProtocol.Invok e(String methodName, Object[] parameters)
TestDataSetColumnBug.localhost.DataSetService.HelloWorld () in c:\inetpub\wwwroot\TestDataSetColumnBug\Web References\localhost\Reference.cs:40 TestDataSetColumnBug.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\testdatasetcolumnbug\webform1.aspx.cs:5 2 System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEv entHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent (NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()
|
|
|
| |
|
|
| |
|
|
|
|
|
|