public void SerializeFaultResponse(Stream stm, XmlRpcFaultException faultEx) { FaultStruct fs; fs.faultCode = faultEx.FaultCode; fs.faultString = faultEx.FaultString; XmlWriter xtw = XmlRpcXmlWriter.Create(stm, XmlRpcFormatSettings); xtw.WriteStartDocument(); xtw.WriteStartElement("", "methodResponse", ""); xtw.WriteStartElement("", "fault", ""); Serialize(xtw, fs, new MappingActions { NullMappingAction = NullMappingAction.Error }); WriteFullEndElement(xtw); WriteFullEndElement(xtw); xtw.Flush(); }
public void SerializeRequest(Stream stm, XmlRpcRequest request) { XmlWriter xtw = XmlRpcXmlWriter.Create(stm, base.XmlRpcFormatSettings); xtw.WriteStartDocument(); xtw.WriteStartElement("", "methodCall", ""); { var mappingActions = new MappingActions(); mappingActions = GetTypeMappings(request.mi, mappingActions); mappingActions = GetMappingActions(request.mi, mappingActions); WriteFullElementString(xtw, "methodName", request.method); if (request.args.Length > 0 || UseEmptyParamsTag) { xtw.WriteStartElement("params"); try { if (!IsStructParamsMethod(request.mi)) { SerializeParams(xtw, request, mappingActions); } else { SerializeStructParams(xtw, request, mappingActions); } } catch (XmlRpcUnsupportedTypeException ex) { throw new XmlRpcUnsupportedTypeException(ex.UnsupportedType, String.Format("A parameter is of, or contains an instance of, " + "type {0} which cannot be mapped to an XML-RPC type", ex.UnsupportedType)); } WriteFullEndElement(xtw); } } WriteFullEndElement(xtw); xtw.Flush(); }