jeudi 14 juin 2018

Soap Web Service XML complex types

I wanted to create web service which should accept Soap request. but the problem is this soap envelop body contains some of the complex XML types

as a very simple example

MY service code

        [WebMethod]
        public int Addition(int a, int b)
        {
            return (a+b);
        }

My Soap Request

             <soap:Body>  
                <Addition xmlns=""http://tempuri.org/"">  
                  <a>" + 10 + @"</a>  
                  <b>" + 20 + @"</b>  
                </Addition>  
              </soap:Body>  

This is working fine.

But if I wanted to send

 <soap:Body>
         <address>
            <street1>33 Court</street1>
            <street2>Oxney Road</street2>
            <county>Cambridgeshire</county>
          </address>
 </soap:Body>  

How would I create my Web Service? I'm sure this is not the correct way. how do I pass

  [WebMethod]
    public string getaddress(string street1, string street2,string county)
    {
        return (street2+street1+county);
    }




Aucun commentaire:

Enregistrer un commentaire