zoukankan      html  css  js  c++  java
  • 2010年07月 小记(telnet,xml命名空间,MaxItemsInObjectGraph, IIS传输限制, memcached Telnet Interface)

    1、在Windows 2008 R2下安装telnet客户端

    PS C:\Users\Administrator> servermanagercmd -install telnet-client

    2、使用XmlSerializer时移除xml声名和默认命名空间。

    代码
    protected string ToXml(object objectToConvert)
    {
    string str = null;

    using (MemoryStream stream = new MemoryStream())
    {
    //XmlWriterSettings.OmitXmlDeclaration移除xml声明
    using (XmlWriter xmlWriter = XmlTextWriter.Create(stream, 
                 new XmlWriterSettings() 
                { OmitXmlDeclaration = true, Encoding = Encoding.UTF8 }))
    {
    //移除命名空间
    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
    ns.Add(
    "", "");

    XmlSerializer serializer
    = new XmlSerializer(objectToConvert.GetType());
    serializer.Serialize(xmlWriter, objectToConvert, ns);

    byte[] buffer = new byte[stream.Length];
    stream.Position
    = 0;
    stream.Read(buffer,
    0, (int)stream.Length);

    str
    = Encoding.UTF8.GetString(buffer);
    xmlWriter.Close();
    }
    stream.Close();
    }

    if (str != null)
    {
    str
    = str.Trim();
    }

    return str;
    }

    3、WCF通信中如果出现序列化错误,如:

    "对象图中可以序列化或反序列化的项目数目上限为“65536”"

    请注意配置MaxItemsInObjectGraph。

    #通过代码配置:

               foreach (var op in client.Endpoint.Contract.Operations)
                {
                    var dataContractBehavior = op.Behaviors[typeof(DataContractSerializerOperationBehavior)]
                    as DataContractSerializerOperationBehavior;
     
                    if (dataContractBehavior != null)
                    {
                        dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
                    }
                }
    

    #通过配置修改:

    <dataContractSerializer maxItemsInObjectGraph="2147483647" />

    4、IIS传输限制

    <httpRuntime maxRequestLength="20000" executionTimeout="600" />


    5、memcached Telnet Interface



  • 相关阅读:
    Dockerfile-ADD命令-转载
    华为云上上传镜像到在线镜像仓库
    什么是4D(DRG、DLG、DOM、DEM)数据
    视频对接资料
    OpenLayer改变切片地图的样式-滤镜效果
    Docker-挂载宿主机目录到容器
    RTSP在线视频环境搭建2-海康摄像头
    配置自己风格的Clang-Format-Xcode
    GCDAsyncUdpSocket的使用
    react-native component function
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1772983.html
Copyright © 2011-2022 走看看