473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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());
}
}

May 26 '06 #1
4 1990
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.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
May 29 '06 #2
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

May 29 '06 #3
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.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
May 29 '06 #4
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?
"Walter Wang [MSFT]" wrote:
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.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights
Sep 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bandzuch martin | last post by:
hello! is there any way how to return custom type for specific class using typeof operator? //my custom type definition class CustomType : System.Type { ... implementation ...
0
by: kaborka | last post by:
I've used the Designer to create a strongly typed Dataset class from a stored procedure definition. I called this class cMyDSraw, and the table within it is called MyTable. The Designer...
3
by: Steve Franks | last post by:
Is there a way I can extend the HttpContext or one of its subclasses to include a property that exposes a custom class of mine to all ASP.NET pages? More specifically, I'd like to use a...
6
by: Shimon Sim | last post by:
Hi I am working on application that need to hold custom user information - Last and first name, email, some other domain related information. I used to create Base class for all my pages. The base...
1
by: Josue Avila M. | last post by:
HI I Design a Class Wich contains severals DataTypes . (2 Strings and Other Data Types from a Class wich i Desing to) Its Something like This <serializable()> Public Class Emitor Public...
5
by: Fabio | last post by:
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...
3
by: Arpan | last post by:
Web Services make use of proxy classes whose methods & properties are accessed in exactly the same way as how a normal class' methods & properties are accessed. So what for does ASP.NET generate...
0
by: sskvp | last post by:
There are millions of samples in the internet explain how to insert a multi node SOAP Header. What I mean is that there are plenty of examples in the internet show how to do the following:...
0
by: adrya1984 | last post by:
Hi, I have a Java service that has the following method signature: @WebMethod(operationName = "getContactList") public MyListClass getContactList(@WebParam(name = "myList")...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.