all groups > dotnet web services > may 2006 >
You're in the

dotnet web services

group:

Generated proxy class conflicts with custom class --REVISED--


Generated proxy class conflicts with custom class --REVISED-- Fabio
5/26/2006 5:11:01 AM
dotnet web services:
An ASP.NET 2.0 web site contains a web form and a web service. The web form
consumes the web service. There is a Book class in the App_Code folder. The
web service exposes a method that returns a Book object. The consumer
includes a method that require a Book parameter. However the Book generated
proxy class conflicts with the Book class in the App_Code folder. Please,
consider the following code. I bet there is an easy way to solve this, but I
have no idea...

Thanks,
Fabio


// App_code/ClassLibrary.cs
namespace ClassLibrary
{
public class Book { ... }
}


// WebService.asmx
namespace WebService
{
[WebService(Namespace = "...")]
public class BookWebService : WebService
{
[WebMethod()]
public ClassLibrary.Book GetBook() { ... }
}
}

// Consumer.aspx
public partial class Consumer : Page
{
protected void Button1_Click(object sender, EventArgs e)
{
WebReference.BookWebService ws =
new WebReference.BookWebService;

private void ReadBook(ClassLibrary.Book book) { ... }

// The following statement does not compile:
// Cannot implicitly convert type 'WebReference.Book' to 'ClassLibrary.Book'
ReadBook(ws.GetBook());
}
}


RE: Generated proxy class conflicts with custom class --REVISED-- wawang NO[at]SPAM online.microsoft.com
5/29/2006 12:00:00 AM
Hello Fabio,

Thank you for your post!

When adding a Web Reference in Visual Studio, it uses the Web Services
Description Language tool (Wsdl.exe) internally to generate proxy code for
XML Web services. The generated types that are used in the proxy class are
based on the contents of the WSDL document that describes the XML Web
service. However, the generated types might not be what you want nor what
you expect. If you do not want to use the generated types, you can change
the generated types to more desirable types. To get the appropriate object
type, you can open the file that contains the generated proxy classes,
manually change the generated method paremeter, and then return types to
the appropriate object types.

In Visual Studio 2005, the generated proxy class source file is not
accessible by default, it's directly compiled into an assembly. So we must
manually generate the proxy class file using Wsdl.exe and modify the class
file later.

So regarding your issue, we can:
1) Remove existing Web Reference;
2) Open "Visual Studio 2005 Command Prompt", run "wsdl.exe /language:cs
/namespace:WebService http://localhost:12345/WebSite1/BookWebService.asmx",
this will generate 'BookWebService.cs' in current folder
3) Copy this file to your project and manually modify related method
parameter or return type to 'ClassLibrary.Book'.

Hope this helps. If there's anything unclear, please feel free to post here.


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

RE: Generated proxy class conflicts with custom class --REVISED-- wawang NO[at]SPAM online.microsoft.com
5/29/2006 12:00:00 AM
Hi Fabio,

Thank you for your update. Have a nice day!

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

RE: Generated proxy class conflicts with custom class --REVISED-- Fabio
5/29/2006 12:15:02 AM
Hello Walter,

Thank you for your reply!

I was afraid that manually editing the generated proxy class(es) would have
been the only solution, because I will have to manually update them in case I
update the web service.

--
Fabio Scagliola
http://fabioscagliola.com


RE: Generated proxy class conflicts with custom class --REVISED-- Hiren
9/14/2006 5:56:01 AM
Hi Walter,

I was facing the same issue, however, since i carried out the steps
mentioned before (placing the manually generated proxy.vb file in the
project), am getting several Error messages stating that various classes are
ambigious in the namespace of the generated proxy class.
e.g. "'GetOtherSystemsCompletedEventArgs' is ambiguous in the namespace
'dmWebRef'"

- Is there any particular area where we need to add the manually generated
proxy class?

Thanks in advance
- Hiren.

- Is there any other setting that needs to be performed for the same?
[quoted text, click to view]
AddThis Social Bookmark Button