本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcSerializer.SerializeResponse方法的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcSerializer.SerializeResponse方法的具体用法?C# XmlRpcSerializer.SerializeResponse怎么用?C# XmlRpcSerializer.SerializeResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CookComputing.XmlRpc.XmlRpcSerializer
的用法示例。
在下文中一共展示了XmlRpcSerializer.SerializeResponse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaoloLiveraniProblem
public void PaoloLiveraniProblem()
{
try
{
XmlRpcResponse resp = new XmlRpcResponse(new DataSet());
Stream responseStream = new MemoryStream();
XmlRpcSerializer serializer = new XmlRpcSerializer();
serializer.SerializeResponse(responseStream, resp);
}
catch(XmlRpcInvalidReturnType ex)
{
string s = ex.Message;
}
}
示例2: Invoke
public Stream Invoke(Stream requestStream)
{
try
{
XmlRpcSerializer serializer = new XmlRpcSerializer();
Type type = this.GetType();
XmlRpcServiceAttribute serviceAttr = (XmlRpcServiceAttribute)
Attribute.GetCustomAttribute(this.GetType(),
typeof(XmlRpcServiceAttribute));
if (serviceAttr != null)
{
if (serviceAttr.XmlEncoding != null)
serializer.XmlEncoding = Encoding.GetEncoding(serviceAttr.XmlEncoding);
serializer.UseIntTag = serviceAttr.UseIntTag;
serializer.UseStringTag = serviceAttr.UseStringTag;
serializer.UseIndentation = serviceAttr.UseIndentation;
serializer.Indentation = serviceAttr.Indentation;
}
XmlRpcRequest xmlRpcReq
= serializer.DeserializeRequest(requestStream, this.GetType());
XmlRpcResponse xmlRpcResp = Invoke(xmlRpcReq);
Stream responseStream = new MemoryStream();
serializer.SerializeResponse(responseStream, xmlRpcResp);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
catch (Exception ex)
{
XmlRpcFaultException fex;
if (ex is XmlRpcException)
fex = new XmlRpcFaultException(0, ((XmlRpcException)ex).Message);
else if (ex is XmlRpcFaultException)
fex = (XmlRpcFaultException)ex;
else
fex = new XmlRpcFaultException(0, ex.Message);
XmlRpcSerializer serializer = new XmlRpcSerializer();
Stream responseStream = new MemoryStream();
serializer.SerializeFaultResponse(responseStream, fex);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
}
示例3: SerializeResponse
void SerializeResponse(
IMessage responseMsg,
ref ITransportHeaders responseHeaders,
ref Stream responseStream)
{
XmlRpcSerializer serializer = new XmlRpcSerializer();
responseStream = new MemoryStream();
responseHeaders = new TransportHeaders();
ReturnMessage retMsg = (ReturnMessage)responseMsg;
if (retMsg.Exception == null)
{
XmlRpcResponse xmlRpcResp = new XmlRpcResponse(retMsg.ReturnValue);
serializer.SerializeResponse(responseStream, xmlRpcResp);
}
else if (retMsg.Exception is XmlRpcFaultException)
{
serializer.SerializeFaultResponse(responseStream,
(XmlRpcFaultException)retMsg.Exception);
}
else
{
serializer.SerializeFaultResponse(responseStream,
new XmlRpcFaultException(1, retMsg.Exception.Message));
}
responseHeaders["Content-Type"] = "text/xml; charset=\"utf-8\"";
}