Structure of a Webservice X Model Class

Asked

Viewed 38 times

2

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

Input XML (Request)

<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 XML above

[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 I have to do ?
The input parameter must be a Dataset instead of a string type ?

I don’t 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.

  • I reworked the post to get a better understanding

  • You shouldn’t envelop this structure into one RetrieveDeviceParentRequest

  • Good morning @Leandro Angelo what would be "envelopar"? as I said I have no domain and time is short, however I have solved the current problem by changing the signature of the web method to: public XmlDocument RetrieveClienteRequest(model model)), the more I came across another problem.

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 is the best way but solved the problem if someone has another alternative thank the comments.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.