Structure of a WebService X Model class

Posted on

Question :

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

Request XML

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

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

[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Device : System.Web.Services.WebService
    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.


Answer :

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; }


        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.


Leave a Reply

Your email address will not be published. Required fields are marked *