Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to create a xml like below:
XML
<?xml version="1.0"?>
<methodCall>
  <methodName />
  <params>
    <param>
       <value>
          <string>12</string>
       </value>
    </param>
  </params>
</methodCall>


My code is On Server:
C#
public string XMLConversion(BaseS exa)
        {
            Stream stm = new MemoryStream();
            XmlRpcRequest req = new XmlRpcRequest();
            req.args = new Object[] { exa };
            XmlRpcSerializer ser = new XmlRpcSerializer();
            ser.SerializeRequest(stm, req);
            stm.Position = 0;
            TextReader tr = new StreamReader(stm);
            string reqstr = tr.ReadToEnd();
            return exa.Val1;
        }


On Client:
C#
 [Serializable]
    public struct BaseS
    {
        //public string val11;
        public string Val1
        {
            set { Val1 = "12"; }
        }
    }
-----------------------------------
   public interface Iname
    {
        [XmlRpcMethod("Server.XmlCnversion")]
        //string XMLConversion(XMLValues exa);
        string XMLConversion(BaseS request);
    }

-------------------------------
 BaseS bs ;
            bs.Val1 = "12";
            try
            {
                IName svr = (IName)Activator.GetObject(
         typeof(IName), "http://localhost:5678/name.rem");
                string s = svr.XMLConversion(bs);
                Console.Write(s);
            }
            catch (XmlRpcFaultException fx)
            {
                Console.Write(fx);
            }



By This above code I am getting below xml

XML
<?xml version="1.0"?>
<methodCall>
  <methodName />
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>Val1</name>
            <value>
              <string>12</string>
            </value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>



Please Help me.

Thanks and Regards!
Kuldeep Dwivedi
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900