Structure of a WebService X Model class

3

I need to do a web service (asmx) where the Request Entry is in this structure:

Request XML

<RetrieveDeviceParentRequest>
         <model query="">
            <keys query="">
               <ConfigurationItem type="String" ></ConfigurationItem>
               <ParentDevice type="String"></ParentDevice>
            </keys>
            <instance>
               <ConfigurationItem type="String"></ ConfigurationItem>
               <ParentDevice type="String" ></ParentDevice>
            </instance>
         </model>
      </RetrieveDeviceParentRequest>

WebMethod
Today I have this Web Method that does not meet the above XML

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Device : System.Web.Services.WebService
{
    [WebMethod]
    public DataTable RetrieveDevice(string RetrieveDeviceRequest)
    {
        DeviceBusiness objDeviceBusiness = new DeviceBusiness();
        return objDeviceBusiness.getDevice(RetrieveDeviceRequest);
    }
}

What do I have to do? Home The input parameter must be a DataSet instead of string type?

I do not have the domain and I would like to have more time to search, but the situation is critical because they will shut down the server and I need to do another web service to replace it.

    
asked by anonymous 04.10.2018 / 15:30

1 answer

0

I created a class called model , keys and instance with the input attributes:

Class model :

public class model
    {
        public keys Keys { get; set; }
        public instance instance { get; set;}
    }

Class keys :

public class keys
    {
        public string ConfigurationItem { get; set; }
        public string ParentDevice { get; set; }
    }

Class instance :

public class instance
    {
        public string ConfigurationItem { get; set; }
        public string ParentDevice { get; set; }

    }

[WebMethod]
        public XmlDocument RetrieveClienteRequest(model model)
        {
            XmlDocument xmlDoc = new XmlDocument();
            ClienteBusiness objClienteBusiness = new ClienteBusiness();
            xmlDoc = objClienteBusiness.getCustomer(model);
            return xmlDoc;
        }

I do not know if it's the best way but solved the problem if someone else had an alternative thank you for the comments.

    
05.10.2018 / 14:02