I'm currently using XML-RPC from http://www.xml-rpc.net/
I've seen hundred of examples getting one result from the service and storing it in a struct, but I need to store "N" values.
I'll explain it better. I have a source file containing, basically this:
public struct estructura
{
public string apiKey;
}
[XmlRpcUrl("http://exam开发者_开发技巧ple.net/api/xmlrpc/thisfile.php")]
public interface IStateName : IXmlRpcProxy
{
[XmlRpcMethod("myserver.search.getSomething")]
XmlRpcStruct busqueda(estructura co);
}
I've also one aspx file with this on PageLoad
protected void Page_Load(object sender, EventArgs e)
{
IStateName proxy = XmlRpcProxyGen.Create<IStateName>();
try
{
estructura uno;
uno.apiKey = "My_API_Key_Value"; // Hidden for security reasons
XmlRpcStruct a = proxy.busqueda(uno);
}
catch (Exception ex)
{
Response.Write("Some error...");
}
}
This actually works, I'm using Fiddler to read HTTP Requests/Responses and all is fine, the service returns this...
HTTP/1.1 200 OK
Date: Tue, 01 Feb 2011 16:06:51 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Pragma: no-cache
Connection: close
XMLRPC-server: SimpleXMLRPC/0.7
Content-Length: 2177
Content-Type: text/xml; charset=UTF-8
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>ATEId</name>
<value>
<string>6</string>
</value>
</member>
<member>
<name>ATEDescripcionEsp</name>
<value>
<string>* No Especificado *</string>
</value>
</member>
</struct>
</value>
</param>
<param>
<value>
<struct>
<member>
<name>ATEId</name>
<value>
<string>10</string>
</value>
</member>
<member>
<name>ATEDescripcionEsp</name>
<value>
<string>Asociaciones de empresas</string>
</value>
</member>
</struct>
</value>
</param>
<param>
[The rest of params...]
</param>
</params>
</methodResponse>
My problem is that "var a" stores ONLY the first "param", I mean, I debugged the code and "a" contains only these entries
Name Value
["ATEDescripcionEsp"] "* No Especificado *"
["ATEId"] "6"
So I only want to store ALL results (next result should be ATEId=10 and ATEDescripcionEsp="Asociaciones de Empresas") from the server response or, If I can't do that, I need to store the plain XML from the response, then I would parse it manually.
It looks like you are returning a set of values. You may want to consider changing the schema of the structure to accept an array or make the struct an array of values.
精彩评论