读取数据已经提交给WCF服务的形式的xmlReading Data That Has Been Submitted To WCF Service in form of xml

- 此内容更新于:2015-01-06
主题:

原文:

Hello guys, I have developing a wcf service using rest with it for consumption on android devices. I want to get the data from the user in form of an complex xml and then save it to the oracle database. Here is what i have implemented till now.

[ServiceContract()]
public interface IDospiDataWebService
{
    [OperationContract]
    [WebInvoke(UriTemplate = "/scheduledata1/new",Method = "POST",RequestFormat=WebMessageFormat.Xml)]
    void scheduledata(ScheduleData_GPLevel document);
} 

[DataContract(Namespace="")]
public class ScheduleData_GPLevel
{
    [DataMember]
    public List<Authenticate> L_Authenticate { get; set; }
    [DataMember]
    public List<CCESchedulePartAData> CCE_SCH_PART_A_Data { get; set; }
}

[Serializable]
public void scheduledata(ScheduleData_GPLevel document)
{
    var stringdata = document.L_Authenticate;
    FileStream fs1 = new FileStream("E:\NewFile.txt", FileMode.OpenOrCreate, FileAccess.Write);
    StreamWriter writer = new StreamWriter(fs1);
    foreach (Authenticate item in stringdata)
    {
        writer.WriteLine(item.Uid);
        writer.WriteLine(item.password);
    }
    writer.Close();
}

When i am passing the following using fiddler post request the file is getting created but the data is not being written in that file. kindly suggest me what i m doing wrong here. Xml is as followed.i want to write the data that has been sended in form of the xml so that i can save it in my database.

<ScheduleData_GPLevel>
    <L_Authenticate>
        <Authenticate>
            <Uid>UID</Uid>
            <password>Password</password>
        </Authenticate>
    </L_Authenticate>
</ScheduleData_GPLevel>
Salvatore Sorbello的回复:正如观察,验证类和CCESchedulePartAData DataContract属性吗?否则我不# 39;认为他们将反序列化

(原文:Just as observation, the Authenticate class and the CCESchedulePartAData have the DataContract attribute? otherwise i don't think they will be deserialized)

Nitin Singh的回复:是的验证类DataContact属性

(原文:yes the Authenticate class has DataContact Attribute with it)

tom的回复:我宁愿IXmlSerializable接口每当谈到在WCF序列化为XML。

(原文:I would prefer IXmlSerializable interface whenever it comes to serialize to XML within WCF.)

Nitin Singh的回复:你能请提供在wcf IXmlSerializable接口的一种实现吗

(原文:Can you please provide some kind of implementation of IXmlSerializable interface in wcf)