473,748 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Name space = "...")]
public class BookWebService : WebService
{
[WebMethod()]
public ClassLibrary.Bo ok GetBook() { ... }
}
}

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

private void ReadBook(ClassL ibrary.Book book) { ... }

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

May 26 '06 #1
4 2008
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:WebSe rvice 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.B ook'.

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. "'GetOtherSyste msCompletedEven tArgs' 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
1006
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
1204
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 generated nested class definitions for cMyDSraw.MyTableDataTable and cMyDSraw.MyTableDataRow. Everything works fine -- I can add a dataset of this class to a form and bind controls to the fields, and they display the results of the sp call properly. ...
3
2974
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 HttpModule to initialize an instance of a custom class, and have this class exposed directly through the HttpRequest for the current user through a property I add to the HttpRequest object. For example, I'd like my developers to be able to use this...
6
2226
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 class would have CurrentUser property that would hold customer class in session and that was fine for all my situations. Now ASP.NET 2.0 came and we have Profile property for pages that could be extended with configuration to have custom...
1
1987
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 NameMsg as String Public KeyCode as String Public Parmas as DAtaParams
5
1249
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 Book object. The consumer expects to receive a Book object. However the Book generated proxy class conflicts with the Book class in the App_Code folder. (See also the following code.) I bet there is an easy way to solve this, but I have no idea......
3
5402
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 proxy classes (using WSDL) which consume more hard disk space & resources? For e.g. consider the following code which exists in a user-defined class file: Imports System Imports System.Data
0
1272
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: <SOAP-ENV:Header> < Security > <Username>AUSER</Username> < Password >APassword</Password> </Security> </SOAP-ENV:Header> But what I want to do is ,
0
1498
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") MyListClass myList) throws IllegalArgumentException { return myList; } public class MyListClass implements Serializable{
0
8995
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9558
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2216
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.