I have 3 classes called Result, Col and Tuple. They essentially represent a database query for serialization. These are exposed using a Web Service (System.Web.Services.WebService). This Web service is then consumed by another web service (System.ServiceModel.ServiceHost) which manipulates the data. The problem is the second web service is consumed by another client it cannot read any of the data.
Here are the 3 classes (With a bit of fluff removed):
Result Class
public class Result
{
public List<Col> Columns { get; set; }
public List<Tuple> Tuples { get; set; }
}
Column Class
public class Col
{
public string ColumnName;
public int? ColumnSequence;
public string DataType;
public int? DataLength;
public int? DataPrecision;
public int? DataScale;
public bool? AllowDbNull;
public bool? IsReadOnly;
public bool? IsLong;
public bool? IsKey;
public string KeyType;
public bool? IsUnique;
public string Description;
}
Tuple
public class Tuple
{
public List<object> Values = new List<object>();
}
Exposing Function
[WebMethod]
public Result Query(string sql, object[] arguments)
{
using (var Conn = Utilities.GetConnection(true))
return Conn.Query(sql, arguments);
}
For some better explanation, I essentially query a database in the second Web Service; however, I recycle the data structure used to store the result. So when the client queries the second web service, it just gives it just fills out the data structure and sends it to the calling client.
Here is the second web Service:
[OperationContract]
public Result QuerySource(String companyCode, String commandText, params object [] arguments)
{
using (var Connection = ClientSettings.Instance.GetOpenConnectionByCode(companyCode))
return Connection.Query(commandText, arguments);
}
I used the following code :
public static string ToXml(this Result result)
{
using (var stringwriter = new StringWriter(CultureInfo.CurrentCulture))
{
new XmlSerializer(result.GetType()).Serialize(stringwriter, result);
return stringwriter.ToString();
}
}
and I get :
<?xml version="1.0" encoding="utf-16"?>
<Result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Columns xmlns="http://pmh.plexxis.com">
<Col>
<ColumnName>DUMMY</ColumnName>
<ColumnSequence xsi:nil="true" />
<DataType>System.String</DataType>
<DataLength xsi:nil="true" />
<DataPrecision xsi:nil="true" />
<DataScale xsi:nil="true" />
<AllowDbNull xsi:nil="true" />
<IsReadOnly>false</IsReadOnly>
<IsLong>false</IsLong>
<IsKey>false</IsKey>
<IsUnique>false</IsUnique>
</Col>
</Columns>
<Tuples xmlns="http://pmh.plexxis.com">
<Tuple>
<Values>
<anyType xsi:type="xsd:string">X</anyType>
</Values>
</Tuple>
</Tuples>
</Result>
I suspect this has smething to do with the name spaces. Any help would be appreciated.