Hello Mark,
Welcome to the MSDN newsgroup.
From your description, you're consuming an ASP.NET webservice in an ASP.NET
web application project. The webservice methods will return some custom
class objects(which is marked as serializable at server-side code) and you
will store them in ASP.NET page's viewstate in web application. However,
you found the client custom classes in the generated proxy classes are not
marked as [serializable] which prevent you from storing them into viewstate
directly, and you're wondering a convenient means to resolve the problem,
correct? If anything I missed, please feel free to let me know.
As for the two ASP.NET applications, are you developing them through VS
2005/.NET 2.0 or VS 2003/.NET 1.1? I've performed some local tests and
found that:
1. When developing through VS 2005/.NET 2.0, if I create a
webreference(proxy classes) for a webservice(i use a class library project
for test), the custom classes in the generated proxy will has
[serializable] marked already.
2. When developing through VS 2003/.NET 1.1, if I create a webreference to
a webservice(also use class library project), the custom classes in the
generated proxy has not been marked with [serializable] automatically.
So are you also developing under VS 2003/.NET 1.1? If so, I think you
current workaround about creating custom classes to used for the webservcie
client proxy is a valid method. Another way is to modify the autogenerated
proxy code, we can do this under the following two conditions:
1) If you are using VS IDE to generate the proxy(add webreference), you
will need to click the webreference node to locate the source code file for
those custom classes(client wrapper) and add the [serializable] attribute
for them manually. The drawback here is that when we update the
webreference, all the code is regenerate and our previous modification will
lose and we have to manually mark them again.
2) We can also consider using the wsdl.exe tool to create the webservice
proxy externally(out of our project) and then import the generated proxy
source code into our project. Then, we can manually customize the source
code and do not worry that the source will be automatically reset.
#Web Services Description Language Tool (Wsdl.exe)
http://msdn2.microsoft.com/en-us/library/7h3ystb6.aspx
I agree to your understanding that this problem is due to the webservice
WSDL's limitation( programing platform neutral) which can not express any
platform specific information(such as the .net framework specific
attributes on class). Anyway, the above things are some of my suggestions.
Hope this helps some.
If you have any other concerns or consideration on this, please feel free
to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial
response from the community or a Microsoft Support Engineer within 1
business day is
acceptable. Please note that each follow up response may take approximately
2 business days
as the support professional working with you may need further investigation
to reach the
most efficient resolution. The offering is not appropriate for situations
that require
urgent, real-time or phone-based interactions or complex project analysis
and dump analysis
issues. Issues of this nature are best handled working with a dedicated
Microsoft Support
Engineer by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.