-1

I'm totally stuck with this for hours now.

I'm consuming a webservice. This Webservice only has one method:

Execute(string strMethod, string strParametersXML)

I've created a Service Reference in Visual Studio for the WebService. This WebSerice can be used to call Methods at the server. So for each method you have different Methodname "strMethod" and different "strParametersXML".

One of this Methods asks for a DataTable as a Parameter in strParameterXML. If i create a datatable in C# and pull the XML with dataTableObject.writeXML(<>) to send it as strParameterXML, the Webservice only returns that the XML could not be parsed.

How does one habe to create a dataTable to send it as a XML-String to a WebService?

4

2 回答 2

1

下面的代码将数据表转换为 Xml 字符串

public string ConvertDataTableToXml(DataTable table)
 {
  MemoryStream stream = new MemoryStream();
  table.WriteXml(stream, true);
  str.Seek(0, SeekOrigin.Begin);
  StreamReader reader = new StreamReader(stream);
  string xmlstr;
  xmlstr = reader.ReadToEnd();
  return (xmlstr);
 }

这可能会帮助您将数据表转换为 XML,该 XML 可以在 Web 服务中重新构建。

最好能获得该特定方法的 WSDL

于 2013-10-31T10:39:12.037 回答
0

我真的不明白你想要完成什么。但是,您可以尝试创建一个 TypedDataSet,在 Visual Studio 中创建它,以便获得一个 .xsd 并公开并使用它?

于 2013-10-31T10:32:50.723 回答