【问题标题】:Netsuite: Download XML Response via APINetsuite:通过 API 下载 XML 响应
【发布时间】:2015-08-03 17:44:33
【问题描述】:

背景:C# 和 NetSuite 相对较新。

给定一个小网络套件方法(通过 SuiteTalk),例如:

private void getInvoice()
{
    RecordRef invoiceRef = new RecordRef
    {
        internalId = "111111",
        type = RecordType.invoice,
        typeSpecified = true
    };

    ReadResponse readResponse = _service.get(invoiceRef);

}//eof

如何将整个 readResponse 作为文件获取?它是前端的 XML 文件...我可以将其下载/读取到此脚本末尾的文件吗?我不知道它是否在这里被视为流,这样将其转换为文件会更容易一些。

【问题讨论】:

  • 响应是流还是字符串:XmlDocument doc = new XmlDocument(); doc.Load(流); doc.LoadXml(string); doc.Save(文件名);

标签: c# xml netsuite


【解决方案1】:

在您的示例中,将向 NetSuite 发出请求,响应将作为 ReadResponse 类加载到您的“readResponse”变量中。然后您需要将返回的记录转换为发票:

Invoice invoiceRecord = (Invoice)readResponse.record;

如果您想将响应写入文件,您可以执行以下操作:

        ReadResponse readResponse = _service.get(invoiceRef);
        FileStream fs = System.IO.File.Create("response.xml");
        XmlSerializer writer = new XmlSerializer(typeof(ReadResponse));
        writer.Serialize(fs, readResponse);
        fs.Close();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-18
    相关资源
    最近更新 更多