DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 07 Aug 2007 17:05:55 +0200,    posted on: microsoft.public.dotnet.framework.aspnet.webservices        back       

Thread Index
  1    Gustaf
          2    John Saunders [MVP] john.saunders at trizetto.com
                 3    Gustaf
                        4    John Saunders [MVP] john.saunders at trizetto.com


Need some help reading instructions   
I found what appears to be the solution to my problem in this old thread:

  http://groups.google.se/group/microsoft.public.dotnet.framework.aspnet.webservices/browse_thread/thread/147cb18619cc937/

Dan Rogers of Microsoft writes:

[...] share the assembly that you use on the client and on
the server, and change the generated proxy method to return a UserList
class.  If you're starting with the generated proxy code, you'll have to
comment out the generated type information, and then add an imports or
using statement, as well as an assembly reference to your project.  This
allows the proxy to see the types defined in your assembly, and then
serialize properly to the more advanced userlist type.

I got a number of questions here, but let's start with these two:

1. Shall the service assembly be added to the client assembly, or vice versa, or both?

2. If the service assembly shall be added to the client assembly, exactly what shall be added? There's no DLL in the web service project folders to add. Is it possible to generate one?

Gustaf
Date:Tue, 07 Aug 2007 17:05:55 +0200   Author:  

Re: Need some help reading instructions   
"Gustaf"  wrote in message 
news:eL0WaSQ2HHA.3916@TK2MSFTNGP02.phx.gbl...

>I found what appears to be the solution to my problem in this old thread:
>
> 
> http://groups.google.se/group/microsoft.public.dotnet.framework.aspnet.webservices/browse_thread/thread/147cb18619cc937/
>
> Dan Rogers of Microsoft writes:
>
> [...] share the assembly that you use on the client and on
> the server, and change the generated proxy method to return a UserList
> class.  If you're starting with the generated proxy code, you'll have to
> comment out the generated type information, and then add an imports or
> using statement, as well as an assembly reference to your project.  This
> allows the proxy to see the types defined in your assembly, and then
> serialize properly to the more advanced userlist type.
>
> I got a number of questions here, but let's start with these two:
>
> 1. Shall the service assembly be added to the client assembly, or vice 
> versa, or both?


Please ignore Mr. Rogers' suggestion. It produces unmaintainable code. 
Consider that most developers expect generated code (the proxy) to be able 
to be regenerated with no ill-effects. Mr. Rogers would have you edit the 
generated proxy file, in the hopes that nobody will ever do an "Update Web 
Reference" command and wipe out your changes.

Also, this suggestion totally violates the encapsulation of the server, 
since now the client is dependent on implementation specifics of the 
service. Those specifics (extra methods on types, for instance), are now 
part of the contract, even though they cannot be described by WSDL.


> 2. If the service assembly shall be added to the client assembly, exactly 
> what shall be added? There's no DLL in the web service project folders to 
> add. Is it possible to generate one?


Mr. Rogers was no doubt assuming that you use an ASP.NET Web Service 
Project, not a Web Service Web Site (or whatever it's called). Those produce 
an assembly.

They produce an assembly which is meant to remain on the server and to never 
be seen by the client.

If you really need more intimacy between the client and the server, then you 
should be using Remoting or WCF, not Web Services.
-- 
John Saunders [MVP]
Date:Tue, 7 Aug 2007 20:27:45 -0400   Author:  

Re: Need some help reading instructions   
John Saunders [MVP] wrote:


> Please ignore Mr. Rogers' suggestion. It produces unmaintainable code. 
> Consider that most developers expect generated code (the proxy) to be 
> able to be regenerated with no ill-effects. Mr. Rogers would have you 
> edit the generated proxy file, in the hopes that nobody will ever do an 
> "Update Web Reference" command and wipe out your changes.


Thank you John. I see no other way than editing the generated code, since it doesn't come out right. After working on this for the past few weeks, I've started to look upon the Add Web Reference wizard (or wsdl.exe) as a tool that does half the job -- and then you have to add to and tweak the code to your liking, and make sure you never use "Update Web Reference".

Like the original poster in the old thread, I need to return a collection class from the web service, but when I create a client and add a web reference to it, the service returns an object array rather than a collection class. Rogers says "This is the default behavior of the proxy generator". I'd say it's a bug. The classes on the client are supposed to *mirror* those on the web service. Instead, the proxy generator removes the collection class and replace its occurence in the web method with an object array, so that

[WebMethod]
public UserList GetUserList()

becomes

[WebMethod]
public User[] GetUserList()

The steps to make this right again is to add a UserList class to the generated classes, and then modify how GetUserList() is defined. The first is simple, but the second is not.


> Also, this suggestion totally violates the encapsulation of the server, 
> since now the client is dependent on implementation specifics of the 
> service. Those specifics (extra methods on types, for instance), are now 
> part of the contract, even though they cannot be described by WSDL.


If it helps the Add Web Reference wizard to produce correct code, I've no problem with it. As I understand Rogers, the reference wouldn't be needed after the proxy class has been created.


> Mr. Rogers was no doubt assuming that you use an ASP.NET Web Service 
> Project, not a Web Service Web Site (or whatever it's called). Those 
> produce an assembly.


I'll look more into the ASP.NET Web Service Application project type.

Gustaf
Date:Wed, 08 Aug 2007 11:32:56 +0200   Author:  

Re: Need some help reading instructions   
"Gustaf"  wrote in message 
news:OPI%23$8Z2HHA.5772@TK2MSFTNGP02.phx.gbl...

> John Saunders [MVP] wrote:
>
>> Please ignore Mr. Rogers' suggestion. It produces unmaintainable code. 
>> Consider that most developers expect generated code (the proxy) to be 
>> able to be regenerated with no ill-effects. Mr. Rogers would have you 
>> edit the generated proxy file, in the hopes that nobody will ever do an 
>> "Update Web Reference" command and wipe out your changes.
>
> Thank you John. I see no other way than editing the generated code, since 
> it doesn't come out right. After working on this for the past few weeks, 
> I've started to look upon the Add Web Reference wizard (or wsdl.exe) as a 
> tool that does half the job -- and then you have to add to and tweak the 
> code to your liking, and make sure you never use "Update Web Reference".
>
> Like the original poster in the old thread, I need to return a collection 
> class from the web service, but when I create a client and add a web 
> reference to it, the service returns an object array rather than a 
> collection class. Rogers says "This is the default behavior of the proxy 
> generator". I'd say it's a bug. The classes on the client are supposed to 
> *mirror* those on the web service. Instead, the proxy generator removes 
> the collection class and replace its occurence in the web method with an 
> object array, so that


The proxy classes are NOT meant to mirror those of the service. This is a 
fundamental misunderstanding of the Web Services platform. Here's how it 
works in .NET:

When you use Add Web Reference, a query is sent to the server with "?WSDL" 
tacked on to the end of it. This causes ASP.NET to create a WSDL and return 
it to the client (which in this case is Visual Studio). VS uses the WSDL to 
create proxy classes.

WSDL depends on XML Schema to describe the types used to communicate to and 
from the web service. XML Schema has no concept of a collection. It only has 
the concept of repeated elements. Therefore, the generated proxy will use an 
array instead of a collection.

The Web Services platform is meant to be cross-platform. As such, it depends 
on industry standards like WSDL and XSD. The consequence of this is that 
you're stuck with sort of a least-common-denominator situation - you can't 
have collections because some platforms don't have collections. The same 
goes for all the other things you can't have, like properties, indexers, 
iterators, methods on non-WebService types, etc.

There is nothing wrong with _adding_ to the generated proxy class. You can 
either derive from it, or else you can add to it through partial classes. If 
you want a nice, convenient, collection-based interface to the web service, 
then you are free to define one on top of the implementation generated by 
Visual Studio. But you should NEVER edit generated code!


> [WebMethod]
> public UserList GetUserList()
>
> becomes
>
> [WebMethod]
> public User[] GetUserList()
>
> The steps to make this right again is to add a UserList class to the 
> generated classes, and then modify how GetUserList() is defined. The first 
> is simple, but the second is not.
>
>> Also, this suggestion totally violates the encapsulation of the server, 
>> since now the client is dependent on implementation specifics of the 
>> service. Those specifics (extra methods on types, for instance), are now 
>> part of the contract, even though they cannot be described by WSDL.
>
> If it helps the Add Web Reference wizard to produce correct code, I've no 
> problem with it. As I understand Rogers, the reference wouldn't be needed 
> after the proxy class has been created.


This is not the case.


>> Mr. Rogers was no doubt assuming that you use an ASP.NET Web Service 
>> Project, not a Web Service Web Site (or whatever it's called). Those 
>> produce an assembly.
>
> I'll look more into the ASP.NET Web Service Application project type.


You should. "Web Sites" are not even a project type. They are useful for 
what they're called - web sites, not for web applications.
-- 
John Saunders [MVP]
Date:Wed, 8 Aug 2007 12:24:14 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us