本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcSerializer.SerializeFaultResponse方法的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcSerializer.SerializeFaultResponse方法的具体用法?C# XmlRpcSerializer.SerializeFaultResponse怎么用?C# XmlRpcSerializer.SerializeFaultResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CookComputing.XmlRpc.XmlRpcSerializer
的用法示例。
在下文中一共展示了XmlRpcSerializer.SerializeFaultResponse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Invoke
public Stream Invoke(Stream requestStream)
{
try
{
var serializer = new XmlRpcResponseSerializer();
var deserializer = new XmlRpcRequestDeserializer();
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) ?? Config.DefaultEncoding;
}
serializer.UseEmptyParamsTag = serviceAttr.UseEmptyElementTags;
serializer.UseIntTag = serviceAttr.UseIntTag;
serializer.UseStringTag = serviceAttr.UseStringTag;
serializer.UseIndentation = serviceAttr.UseIndentation;
serializer.Indentation = serviceAttr.Indentation;
}
XmlRpcRequest xmlRpcReq = deserializer.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;
}
}
示例2: Invoke
public Stream Invoke(Stream requestStream)
{
try
{
var serializer = new XmlRpcResponseSerializer();
var deserializer = new XmlRpcRequestDeserializer();
var serviceAttr = Attribute.GetCustomAttribute(GetType(), typeof(XmlRpcServiceAttribute)) as XmlRpcServiceAttribute;
if (serviceAttr != null)
{
if (serviceAttr.XmlEncoding != null)
serializer.XmlEncoding = Encoding.GetEncoding(serviceAttr.XmlEncoding);
serializer.UseEmptyParamsTag = serviceAttr.UseEmptyElementTags;
serializer.UseIntTag = serviceAttr.UseIntTag;
serializer.UseStringTag = serviceAttr.UseStringTag;
serializer.UseIndentation = serviceAttr.UseIndentation;
serializer.Indentation = serviceAttr.Indentation;
}
var xmlRpcReq = deserializer.DeserializeRequest(requestStream, GetType());
var xmlRpcResp = Invoke(xmlRpcReq);
var responseStream = new MemoryStream();
serializer.SerializeResponse(responseStream, xmlRpcResp);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
catch (Exception ex)
{
XmlRpcFaultException fex;
var xmlRpcException = ex as XmlRpcException;
if (xmlRpcException != null)
fex = new XmlRpcFaultException(0, xmlRpcException.Message);
else
{
fex = (ex as XmlRpcFaultException)
?? new XmlRpcFaultException(0, ex.Message);
}
var serializer = new XmlRpcSerializer();
var responseStream = new MemoryStream();
serializer.SerializeFaultResponse(responseStream, fex);
responseStream.Seek(0, SeekOrigin.Begin);
return responseStream;
}
}
示例3: ProcessMessage
public ServerProcessing ProcessMessage(
IServerChannelSinkStack sinkStack,
IMessage requestMsg,
ITransportHeaders requestHeaders,
Stream requestStream,
out IMessage responseMsg,
out ITransportHeaders responseHeaders,
out Stream responseStream
)
{
// use presence of SOAPAction header to determine if this is a SOAP
// request - if so pass onto next sink in chain
string soapAction = (string) requestHeaders["SOAPAction"];
if (soapAction != null)
{
return m_next.ProcessMessage(sinkStack, requestMsg, requestHeaders,
requestStream, out responseMsg, out responseHeaders,
out responseStream);
}
// for time being assume we have an XML-RPC request (need to improve
// this in case there are other non-SOAP formatters in the chain)
try
{
MethodCall mthdCall = DeserializeRequest(requestHeaders, requestStream);
sinkStack.Push(this, mthdCall);
// forward to next sink in chain - pass request stream as null to
// indicate that we have deserialized the request
m_next.ProcessMessage(sinkStack, mthdCall, requestHeaders, null,
out responseMsg, out responseHeaders, out responseStream);
SerializeResponse(responseMsg, ref responseHeaders, ref responseStream);
}
catch (Exception ex)
{
responseMsg = new ReturnMessage(ex, (IMethodCallMessage)requestMsg);
responseStream = new MemoryStream();
XmlRpcFaultException fex = new XmlRpcFaultException(0, ex.Message);
XmlRpcSerializer serializer = new XmlRpcSerializer();
serializer.SerializeFaultResponse(responseStream,
(XmlRpcFaultException)fex);
responseHeaders = new TransportHeaders();
}
return ServerProcessing.Complete;
}
示例4: 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\"";
}