Receiving a DTO From an ASP.NET Web Service

后端 未结 3 1633
情书的邮戳
情书的邮戳 2021-01-28 07:10

If I run ASP.NET, and I am accessing a foreign asmx web service that returns a List of Person objects, where Person is some DTO defined by the foreign company, then what is the

相关标签:
3条回答
  • 2021-01-28 07:28

    If you are using a .NET Web Application (as opposed to a Web Site), I would add a service reference, let Visual Studio build all the classes for me and use those.

    http://msdn.microsoft.com/en-us/library/bb386382.aspx

    0 讨论(0)
  • 2021-01-28 07:36

    Please generate a Proxy Class for the Web Service. It can be a C# .cs file. It should contain the definition of the DTO which you can use in your client.

    0 讨论(0)
  • 2021-01-28 07:46

    Define your own DTO and map the foreign object (from a proxy class or something) to your own. Take only what you need. This gives you a layer of abstraction from the webservice if it ever changes.

    http://automapper.codeplex.com/ might be helpful for the mappings.

    0 讨论(0)
提交回复
热议问题