Re: Web service, generics and complex data types



"Mike" <mike@xxxxxxxxxxx> wrote in message news:319203BAFD7A4B78B5378D3CB3A385B2@xxxxxxxxx
HI,



I'm having some problems with web services, as I cannot make them do
what I need.





I have a class called Order that has more classes inside.

For example, I have Order. Addresses, in this case Addresses is a
generic collection as (of Address)



What I want is that my web service returns an object Order as it is,
with all its properties as it is mean to be.



Right now, the proxy generated when I reference the service
(Reference.vb) downgrades the object Addresses to an object Address.



What I need is the ability to get (thru the web service) an Order object
as it was created, not downgraded, and also I need the ability to pass
to the web service an object Order so I can persist this object to the
DB thru the web service.

The Web Services platform is meant to be platform-neutral. Generics, in particular generic collections, are a platform-specific feature. As such, they should not be used in web services. In fact, there is no way in WSDL and XSD to describe a generic collection.

But I suspect that you don't actually need a generic collection. You need to pass a set of Address data. Note that I don't say that you need to pass a set of Address objects, because that is fundamentally impossible. But you can pass a set of the data that an Address object is composed of. It seems quite old-fashioned, but you should be passing arrays of Address.


There is a lot of behind-the-scenes magic that makes it easy to use Web Services. That is, they are easy to use, until they aren't easy to use any more.

This magic obscures the process, so I'll briefly describe the process.

1) A client-side development tool (maybe VS "Add Web Reference") requests the WSDL from the server
2) ASP.NET on the server uses the .asmx file to create an instance of the web service class. It uses Reflection to examine the Web Service class and the other types used by that class as parameters and return values. It then creates a WSDL and schema that describes what it found, and returns that to the client-side development tool
3) The client-side tool will probably use the WSDL and schema to create proxy classes. These will be classes that can be serialized into XML that validates against the schema in the WSDL file, and classes that can make calls to the service described by the WSDL
4) You use the proxy classes to produce your client program

5) At run-time, your client program uses the proxy classes to create proxy objects that get serialized to XML that gets sent to the server, sends it to the server, gets XML responses from the server and deserializes the responses back into proxy objects

Note that it is impossible for the client to use your server-side classes, so it will never be using your Order object "as it was created". The client will never be using your Order object at all! If you have a design that depends on the client using your actual Order object, then you should be using .NET Remoting and not Web Services.
--
John Saunders [MVP]

.



Relevant Pages

  • Re: Still Need desperate help to start with ASP NET - simplified problems - HELP!!
    ... You could do it as a web service. ... The handler can draw on the webservice for information and db lookup. ... IE posts data AJAX to handler on web server ... featured application (say thick client) which does a lot of complicate ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Impersonated login to web service from outside domain
    ... the client is part of the domain group. ... : integrated windows auth fails. ... You can try creating an identical local user on the server (as the one you ... next call to the web service (ie. the process requiring the credentials to ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: WSDL.exe vs. "Add Web Reference"
    ... For example this complexType: ... I them created a WSDL using the XSD. ... Then I placed this file in an "Empty Web Project", added a Web Service, made ... If I do all these steps correctly the client should ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Unable to access AS2k from Win 2k m/c URGENT!!!!!!
    ... No, the Win2k machine just needs to have XMLA SDK and/or ADOMD.NET, MSXML4 ... > Analysis server need more credentials than specified in my ... the same machine as the ADOMD.NET client. ... Why do you need this web service ...
    (microsoft.public.data.xmlanalysis)
  • Re: Web service testing
    ... To test if my code was faulty or not, I back-ported the web service to a standard 2.0 web service using Visual Studio 2005. ... The service is run under IIS on a Windows 2003 server, so there are no server side connection limits that can explain this. ... ASP.NET webservice application. ... In addition, since the problems occur at client, you can use Visual studio ...
    (microsoft.public.dotnet.framework.webservices)

Loading