public SerializeResponse ( Stream stm, CookComputing.XmlRpc.XmlRpcResponse response ) : void | ||
stm | Stream | |
response | CookComputing.XmlRpc.XmlRpcResponse | |
return | void |
public Stream Invoke(Stream requestStream) { try { XmlRpcSerializer serializer = new XmlRpcSerializer(); 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); } }
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\""; }
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); } }
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; } }
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; } }
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\""; }