本文整理汇总了C#中CookComputing.XmlRpc.XmlRpcRequest类的典型用法代码示例。如果您正苦于以下问题:C# XmlRpcRequest类的具体用法?C# XmlRpcRequest怎么用?C# XmlRpcRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlRpcRequest类属于CookComputing.XmlRpc命名空间,在下文中一共展示了XmlRpcRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SerializeRequest
public void SerializeRequest(Stream stm, XmlRpcRequest request)
{
var xtw = XmlRpcXmlWriter.Create(stm, XmlRpcFormatSettings);
xtw.WriteStartDocument();
xtw.WriteStartElement(string.Empty, "methodCall", string.Empty);
{
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();
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:34,代码来源:XmlRpcRequestSerializer.cs
示例2: SerializeRequestNil
public void SerializeRequestNil()
{
Stream stm = new MemoryStream();
XmlRpcRequest req = new XmlRpcRequest();
req.args = new Object[] { null, 1234567 };
req.method = "NilMethod";
req.mi = this.GetType().GetMethod("NilMethod");
var ser = new XmlRpcRequestSerializer();
ser.Indentation = 4;
ser.SerializeRequest(stm, req);
stm.Position = 0;
TextReader tr = new StreamReader(stm);
string reqstr = tr.ReadToEnd();
Assert.AreEqual(
@"<?xml version=""1.0""?>
<methodCall>
<methodName>NilMethod</methodName>
<params>
<param>
<value>
<nil />
</value>
</param>
<param>
<value>
<i4>1234567</i4>
</value>
</param>
</params>
</methodCall>", reqstr);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:31,代码来源:NilTest.cs
示例3: SerializeRequestNilParams
public void SerializeRequestNilParams()
{
var stm = new MemoryStream();
var req = new XmlRpcRequest();
req.Args = new Object[] { new object[] { 1, null, 2 } };
req.Method = "NilParamsMethod";
req.Mi = GetType().GetMethod("NilParamsMethod");
var ser = new XmlRpcRequestSerializer();
ser.Indentation = 4;
ser.SerializeRequest(stm, req);
stm.Position = 0;
var tr = new StreamReader(stm);
tr.ReadToEnd().ShouldBe(
@"<?xml version=""1.0""?>
<methodCall>
<methodName>NilParamsMethod</methodName>
<params>
<param>
<value>
<i4>1</i4>
</value>
</param>
<param>
<value>
<nil />
</value>
</param>
<param>
<value>
<i4>2</i4>
</value>
</param>
</params>
</methodCall>");
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:35,代码来源:NilTest.cs
示例4: XmlRpcAsyncResult
//internal members
internal XmlRpcAsyncResult(
XmlRpcClientProtocol ClientProtocol,
XmlRpcRequest XmlRpcReq,
Encoding XmlEncoding,
bool useEmptyParamsTag,
bool useIndentation,
int indentation,
bool UseIntTag,
bool UseStringTag,
WebRequest Request,
AsyncCallback UserCallback,
object UserAsyncState,
int retryNumber)
{
xmlRpcRequest = XmlRpcReq;
clientProtocol = ClientProtocol;
request = Request;
userAsyncState = UserAsyncState;
userCallback = UserCallback;
_completedSynchronously = true;
xmlEncoding = XmlEncoding;
_useEmptyParamsTag = useEmptyParamsTag;
_useIndentation = useIndentation;
_indentation = indentation;
this.UseIntTag = UseIntTag;
this.UseStringTag = UseStringTag;
}
开发者ID:stavrossk,项目名称:Automated-Video-Subtitle-Importer-for-MeediOS,代码行数:28,代码来源:XmlRpcAsyncResult.cs
示例5: Invoke
public XmlRpcResponse Invoke(XmlRpcRequest request)
{
MethodInfo mi = null;
if (request.mi != null)
{
mi = request.mi;
}
else
{
mi = this.GetType().GetMethod(request.method);
}
// exceptions thrown during an MethodInfo.Invoke call are
// package as inner of
Object reto;
try
{
reto = mi.Invoke(this, request.args);
}
catch(Exception ex)
{
if (ex.InnerException != null)
throw ex.InnerException;
throw ex;
}
XmlRpcResponse response = new XmlRpcResponse(reto);
return response;
}
开发者ID:bricel,项目名称:DrutNet,代码行数:27,代码来源:XmlRpcServerProtocol.cs
示例6: SerializeObjectParams
public void SerializeObjectParams()
{
Stream stm = new MemoryStream();
XmlRpcRequest req = new XmlRpcRequest();
req.args = new Object[] { new object[] { 1, "one" } };
req.method = "Foo";
req.mi = typeof(IFoo).GetMethod("Foo");
var ser = new XmlRpcRequestSerializer();
ser.SerializeRequest(stm, req);
stm.Position = 0;
TextReader tr = new StreamReader(stm);
string reqstr = tr.ReadToEnd();
Assert.AreEqual(
@"<?xml version=""1.0""?>
<methodCall>
<methodName>Foo</methodName>
<params>
<param>
<value>
<i4>1</i4>
</value>
</param>
<param>
<value>
<string>one</string>
</value>
</param>
</params>
</methodCall>", reqstr);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:30,代码来源:paramstest.cs
示例7: Invoke
public XmlRpcResponse Invoke(XmlRpcRequest request)
{
MethodInfo mi = null;
if (request.mi != null)
{
mi = request.mi;
}
else
{
mi = this.GetType().GetMethod(request.method);
}
// exceptions thrown during an MethodInfo.Invoke call are
// package as inner of
Object reto;
try
{
reto = mi.Invoke(this, request.args);
}
catch(Exception ex)
{
if (ex.InnerException != null)
throw ex.InnerException;
throw ex;
}
// methods which have void return type always return integer 0
// because XML-RPC doesn't support no return type (could use nil
// but want to maintain backwards compatibility in this area)
if (mi != null && mi.ReturnType == typeof(void))
reto = 0;
XmlRpcResponse response = new XmlRpcResponse(reto);
return response;
}
开发者ID:christianeisendle,项目名称:nunit-testlink-adapter,代码行数:32,代码来源:XmlRpcServerProtocol.cs
示例8: SerializeRequest
/// <summary>
///
/// </summary>
/// <param name="stm"></param>
/// <param name="request"></param>
public void SerializeRequest(Stream stm, XmlRpcRequest request)
{
XmlWriter xtw = XmlRpcXmlWriter.Create(stm, base.XmlRpcFormatSettings);
xtw.WriteStartDocument();
xtw.WriteStartElement("", "methodCall", "");
{
// TODO: use global action setting
NullMappingAction mappingAction = NullMappingAction.Error;
WriteFullElementString(xtw, "methodName", request.method);
if (request.args.Length > 0 || UseEmptyParamsTag)
{
xtw.WriteStartElement("params");
try
{
if (!IsStructParamsMethod(request.mi))
SerializeParams(xtw, request, mappingAction);
else
SerializeStructParams(xtw, request, mappingAction);
}
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();
}
开发者ID:Orvid,项目名称:Zutubi.Pulse.Api,代码行数:37,代码来源:XmlRpcRequestSerializer.cs
示例9: XmlRpcAsyncResult
//internal members
internal XmlRpcAsyncResult(
XmlRpcClientProtocol ClientProtocol,
XmlRpcRequest XmlRpcReq,
XmlRpcFormatSettings xmlRpcFormatSettings,
WebRequest Request,
AsyncCallback UserCallback,
object UserAsyncState)
{
XmlRpcRequest = XmlRpcReq;
_clientProtocol = ClientProtocol;
_request = Request;
_userAsyncState = UserAsyncState;
_userCallback = UserCallback;
_completedSynchronously = true;
XmlRpcFormatSettings = xmlRpcFormatSettings;
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:17,代码来源:XmlRpcAsyncResult.cs
示例10: XmlRpcAsyncResult
//internal members
internal XmlRpcAsyncResult(
XmlRpcClientProtocol ClientProtocol,
XmlRpcRequest XmlRpcReq,
XmlRpcFormatSettings xmlRpcFormatSettings,
WebRequest Request,
AsyncCallback UserCallback,
object UserAsyncState,
int retryNumber)
{
xmlRpcRequest = XmlRpcReq;
clientProtocol = ClientProtocol;
request = Request;
userAsyncState = UserAsyncState;
userCallback = UserCallback;
completedSynchronously = true;
XmlRpcFormatSettings = xmlRpcFormatSettings;
}
开发者ID:hanson-huang,项目名称:cms,代码行数:18,代码来源:XmlRpcAsyncResult.cs
示例11: SerializeParams
void SerializeParams(XmlWriter xtw, XmlRpcRequest request,
MappingActions mappingActions)
{
ParameterInfo[] pis = null;
if (request.mi != null)
{
pis = request.mi.GetParameters();
}
for (int i = 0; i < request.args.Length; i++)
{
var paramMappingActions = pis == null ? mappingActions
: GetMappingActions(pis[i], mappingActions);
if (pis != null)
{
if (i >= pis.Length)
throw new XmlRpcInvalidParametersException("Number of request "
+ "parameters greater than number of proxy method parameters.");
if (i == pis.Length - 1
&& Attribute.IsDefined(pis[i], typeof(ParamArrayAttribute)))
{
Array ary = (Array)request.args[i];
foreach (object o in ary)
{
//if (o == null)
// throw new XmlRpcNullParameterException(
// "Null parameter in params array");
xtw.WriteStartElement("", "param", "");
Serialize(xtw, o, paramMappingActions);
WriteFullEndElement(xtw);
}
break;
}
}
//if (request.args[i] == null)
//{
// throw new XmlRpcNullParameterException(String.Format(
// "Null method parameter #{0}", i + 1));
//}
xtw.WriteStartElement("", "param", "");
Serialize(xtw, request.args[i], paramMappingActions);
WriteFullEndElement(xtw);
}
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:43,代码来源:XmlRpcRequestSerializer.cs
示例12: Class
public void Class()
{
Stream stm = new MemoryStream();
XmlRpcRequest req = new XmlRpcRequest();
TestClass arg = new TestClass();
arg._int = 456;
arg._string = "Test Class";
req.Args = new object[] { arg };
req.Method = "Foo";
var ser = new XmlRpcRequestSerializer();
ser.SerializeRequest(stm, req);
stm.Position = 0;
TextReader tr = new StreamReader(stm);
string reqstr = tr.ReadToEnd();
Assert.AreEqual(@"<?xml version=""1.0""?>
<methodCall>
<methodName>Foo</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>_int</name>
<value>
<i4>456</i4>
</value>
</member>
<member>
<name>_string</name>
<value>
<string>Test Class</string>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>", reqstr);
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:40,代码来源:serializetest.cs
示例13: SerializeStructParams
void SerializeStructParams(
XmlWriter xtw,
XmlRpcRequest request,
MappingActions mappingActions)
{
var pis = request.Mi.GetParameters();
if (request.Args.Length > pis.Length)
throw new XmlRpcInvalidParametersException(
"Number of request parameters greater than number of proxy method parameters.");
if (Attribute.IsDefined(pis[request.Args.Length - 1],
typeof(ParamArrayAttribute)))
{
throw new XmlRpcInvalidParametersException(
"params parameter cannot be used with StructParams.");
}
xtw.WriteStartElement("", "param", "");
xtw.WriteStartElement("", "value", "");
xtw.WriteStartElement("", "struct", "");
for (int i = 0; i < request.Args.Length; i++)
{
if (request.Args[i] == null)
{
throw new XmlRpcNullParameterException(
string.Format(
"Null method parameter #{0}",
i + 1));
}
xtw.WriteStartElement("", "member", "");
WriteFullElementString(xtw, "name", pis[i].Name);
Serialize(xtw, request.Args[i], mappingActions);
WriteFullEndElement(xtw);
}
WriteFullEndElement(xtw);
WriteFullEndElement(xtw);
WriteFullEndElement(xtw);
}
开发者ID:magicmonty,项目名称:xmlrpcnet,代码行数:39,代码来源:XmlRpcRequestSerializer.cs
示例14: DeserializeRequest
public XmlRpcRequest DeserializeRequest(XmlDocument xdoc, Type svcType)
{
XmlRpcRequest request = new XmlRpcRequest();
XmlNode callNode = xdoc.SelectSingleNode("./methodCall");
if (callNode == null)
{
throw new XmlRpcInvalidXmlRpcException(
"Request XML not valid XML-RPC - missing methodCall element.");
}
XmlNode methodNode = callNode.SelectSingleNode("./methodName");
if (methodNode == null)
{
throw new XmlRpcInvalidXmlRpcException(
"Request XML not valid XML-RPC - missing methodName element.");
}
request.method = methodNode.FirstChild.Value;
if (request.method == "")
{
throw new XmlRpcInvalidXmlRpcException(
"Request XML not valid XML-RPC - empty methodName.");
}
request.mi = null;
ParameterInfo[] pis = new ParameterInfo[0];
if (svcType != null)
{
// retrieve info for the method which handles this XML-RPC method
XmlRpcServiceInfo svcInfo
= XmlRpcServiceInfo.CreateServiceInfo(svcType);
request.mi = svcInfo.GetMethodInfo(request.method);
// if a service type has been specified and we cannot find the requested
// method then we must throw an exception
if (request.mi == null)
{
string msg = String.Format("unsupported method called: {0}",
request.method);
throw new XmlRpcUnsupportedMethodException(msg);
}
// method must be marked with XmlRpcMethod attribute
Attribute attr = Attribute.GetCustomAttribute(request.mi,
typeof(XmlRpcMethodAttribute));
if (attr == null)
{
throw new XmlRpcMethodAttributeException(
"Method must be marked with the XmlRpcMethod attribute.");
}
pis = request.mi.GetParameters();
}
XmlNode paramsNode = callNode.SelectSingleNode("./params");
if (paramsNode == null)
{
if (svcType != null)
{
if (pis.Length == 0)
{
request.args = new object[0];
return request;
}
else
{
throw new XmlRpcInvalidParametersException(
"Method takes parameters and params element is missing.");
}
}
else
{
request.args = new object[0];
return request;
}
}
XmlNodeList paramNodes = paramsNode.SelectNodes("./param");
int paramsPos = GetParamsPos(pis);
if (paramNodes.Count < paramsPos)
{
throw new XmlRpcInvalidParametersException(
"Method takes parameters and there is incorrect number of param "
+ "elements.");
}
ParseStack parseStack = new ParseStack("request");
// TODO: use global action setting
MappingAction mappingAction = MappingAction.Error;
int paramObjCount = (paramsPos == -1 ?paramNodes.Count : paramsPos + 1);
Object[] paramObjs = new Object[paramObjCount];
// parse ordinary parameters
int ordinaryParams = (paramsPos == -1 ?paramNodes.Count :paramsPos);
for (int i = 0; i < ordinaryParams; i++)
{
XmlNode paramNode = paramNodes[i];
XmlNode valueNode = paramNode.SelectSingleNode("./value");
if (valueNode == null)
throw new XmlRpcInvalidXmlRpcException("Missing value element.");
XmlNode node = valueNode.SelectSingleNode("./*");
if (node == null)
node = valueNode.FirstChild;
if (svcType != null)
{
parseStack.Push(String.Format("parameter {0}", i + 1));
// TODO: why following commented out?
// parseStack.Push(String.Format("parameter {0} mapped to type {1}",
// i, pis[i].ParameterType.Name));
paramObjs[i] = ParseValue(node, pis[i].ParameterType, parseStack,
//.........这里部分代码省略.........
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:101,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs
示例15: SerializeRequest
public void SerializeRequest(Stream stm, XmlRpcRequest request)
{
XmlTextWriter xtw = new XmlTextWriter(stm, m_encoding);
ConfigureXmlFormat(xtw);
xtw.WriteStartDocument();
xtw.WriteStartElement("", "methodCall", "");
{
ParameterInfo[] pis = null;
if (request.mi != null)
{
pis = request.mi.GetParameters();
}
// TODO: use global action setting
MappingAction mappingAction = MappingAction.Error;
if (request.xmlRpcMethod == null)
xtw.WriteElementString("methodName", request.method);
else
xtw.WriteElementString("methodName", request.xmlRpcMethod);
if (request.args.Length > 0 || UseEmptyParamsTag)
{
xtw.WriteStartElement("", "params", "");
try
{
for (int i = 0; i < request.args.Length; i++)
{
if (pis != null)
{
if (i >= pis.Length)
throw new XmlRpcInvalidParametersException("Number of request "
+ "parameters greater than number of proxy method parameters.");
if (Attribute.IsDefined(pis[i], typeof(ParamArrayAttribute)))
{
Array ary = (Array)request.args[i];
foreach (object o in ary)
{
if (o == null)
throw new XmlRpcNullParameterException(
"Null parameter in params array");
xtw.WriteStartElement("", "param", "");
Serialize(xtw, o, mappingAction);
xtw.WriteEndElement();
}
break;
}
}
if (request.args[i] == null)
{
throw new XmlRpcNullParameterException(String.Format(
"Null method parameter #{0}", i + 1));
}
xtw.WriteStartElement("", "param", "");
Serialize(xtw, request.args[i], mappingAction);
xtw.WriteEndElement();
}
}
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));
}
xtw.WriteEndElement();
}
}
xtw.WriteEndElement();
xtw.Flush();
}
开发者ID:molotovbliss,项目名称:csharlibformagexmlrpcapi,代码行数:68,代码来源:Copy+of+XmlRpcSerializer+-+preservewhitepace.cs
示例16: MakeXmlRpcRequest
XmlRpcRequest MakeXmlRpcRequest(WebRequest webReq, MethodInfo mi,
object[] parameters, object clientObj, string xmlRpcMethod,
Guid proxyId)
{
webReq.Method = "POST";
webReq.ContentType = "text/xml";
string rpcMethodName = XmlRpcTypeInfo.GetRpcMethodName(mi);
XmlRpcRequest req = new XmlRpcRequest(rpcMethodName, parameters, mi,
xmlRpcMethod, proxyId);
return req;
}
开发者ID:Orvid,项目名称:Zutubi.Pulse.Api,代码行数:11,代码来源:XmlRpcClientProtocol.cs
示例17: ReadResponse
XmlRpcResponse ReadResponse(
XmlRpcRequest req,
WebResponse webResp,
Stream respStm)
{
HttpWebResponse httpResp = (HttpWebResponse)webResp;
if (httpResp.StatusCode != HttpStatusCode.OK)
{
// status 400 is used for errors caused by the client
// status 500 is used for server errors (not server application
// errors which are returned as fault responses)
if (httpResp.StatusCode == HttpStatusCode.BadRequest)
throw new XmlRpcException(httpResp.StatusDescription);
else
throw new XmlRpcServerException(httpResp.StatusDescription);
}
var deserializer = new XmlRpcResponseDeserializer();
deserializer.NonStandard = _nonStandard;
Type retType = req.mi.ReturnType;
XmlRpcResponse xmlRpcResp
= deserializer.DeserializeResponse(respStm, retType);
return xmlRpcResp;
}
开发者ID:Orvid,项目名称:Zutubi.Pulse.Api,代码行数:23,代码来源:XmlRpcClientProtocol.cs
示例18: SerializeMassimo
public void SerializeMassimo()
{
object[] param1 = new object[] { "test/Gain1", "Gain", 1, 1,
new double[] { 0.5 } };
object[] param2 = new object[] { "test/METER", "P1", 1, 1,
new double[] { -1.0 } };
Stream stm = new MemoryStream();
XmlRpcRequest req = new XmlRpcRequest();
req.args = new Object[] { "IFTASK",
new object[] { param1, param2 } };
req.method = "Send_Param";
req.mi = this.GetType().GetMethod("Send_Param");
var ser = new XmlRpcRequestSerializer();
ser.SerializeRequest(stm, req);
stm.Position = 0;
TextReader tr = new StreamReader(stm);
string reqstr = tr.ReadToEnd();
Assert.AreEqual(massimoRequest, reqstr);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:19,代码来源:paramstest.cs
示例19: SerializeRequest
public void SerializeRequest()
{
Stream stm = new MemoryStream();
XmlRpcRequest req = new XmlRpcRequest();
req.args = new Object[] { IntEnum.Two };
req.method = "Foo";
var ser = new XmlRpcRequestSerializer();
ser.SerializeRequest(stm, req);
stm.Position = 0;
TextReader tr = new StreamReader(stm);
string reqstr = tr.ReadToEnd();
Assert.AreEqual(
@"<?xml version=""1.0""?>
<methodCall>
<methodName>Foo</methodName>
<params>
<param>
<value>
<i4>2</i4>
</value>
</param>
</params>
</methodCall>", reqstr);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:25,代码来源:enumtest.cs
示例20: SerializeIntNoParams
public void SerializeIntNoParams()
{
Stream stm = new MemoryStream();
XmlRpcRequest req = new XmlRpcRequest();
req.args = new object[] { new int[] { 1, 2, 3 } };
req.method = "BarNotParams";
req.mi = typeof(IFoo).GetMethod("BarNotParams");
var ser = new XmlRpcRequestSerializer();
ser.SerializeRequest(stm, req);
stm.Position = 0;
TextReader tr = new StreamReader(stm);
string reqstr = tr.ReadToEnd();
Assert.AreEqual(
@"<?xml version=""1.0""?>
<methodCall>
<methodName>BarNotParams</methodName>
<params>
<param>
<value>
<array>
<data>
<value>
<i4>1</i4>
</value>
<value>
<i4>2</i4>
</value>
<value>
<i4>3</i4>
</value>
</data>
</array>
</value>
</param>
</params>
</methodCall>", reqstr);
}
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:37,代码来源:paramstest.cs
注:本文中的CookComputing.XmlRpc.XmlRpcRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论