472,352 Members | 1,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

adding methods/properties runtime for web services

Hi,

I have been searching on this topic for quite sometime and didnt get
any answer.
Is there a way I can extend/add methods/properties to a C# class during
runtime.

eg.,
I have class:
public class MyClass {
private string identity;
}

So when running the program using this class I want to add a attribute
called "name" of type "string". Or say I want to make this class extend
some other class in runtime. Or add method called getIdentity() in
runtime.

Is any of the above possible? Or is it too much to ask?

To give you some background as to why I need this. We are using wsdl
tool to generate client proxy classes using .wsdl file. We need to add
some extra re-wiring to the classes generated in addition to the
relationships already in the schema which was part of wsdl file.

Or is it possible to override wsdl generation and catch the events
generated to add additional code during generation.

Any suggestion/documentation pointing to these aspects will be very
helpful.

Thanks in advance for all the help!!

Jul 21 '05 #1
2 2202
You can create new types with new methods at runtime using
Reflection.Emit, but I really don't think that is what you want.

The WSDL proxy files do not have to be created at runtime (I'm not even
sure how to do that). They can be created at design time by adding a
reference to a web service using VS.NET, or using the WSDL.EXE tool.
Both solutions create a .cs class file, which you are free to edit
during design time to add whatever methods you need.
ma*************@gmail.com wrote:
Hi,

I have been searching on this topic for quite sometime and didnt get
any answer.
Is there a way I can extend/add methods/properties to a C# class during
runtime.

eg.,
I have class:
public class MyClass {
private string identity;
}

So when running the program using this class I want to add a attribute
called "name" of type "string". Or say I want to make this class extend
some other class in runtime. Or add method called getIdentity() in
runtime.

Is any of the above possible? Or is it too much to ask?

To give you some background as to why I need this. We are using wsdl
tool to generate client proxy classes using .wsdl file. We need to add
some extra re-wiring to the classes generated in addition to the
relationships already in the schema which was part of wsdl file.

Or is it possible to override wsdl generation and catch the events
generated to add additional code during generation.

Any suggestion/documentation pointing to these aspects will be very
helpful.

Thanks in advance for all the help!!

Jul 21 '05 #2
First of all thanks very much for the quick responses.

Joshua,
I am using the wsdl.exe to generate the .cs file. My problem is it only
generates properties for the elements in the schema. Its very difficult
to navigate to a different object if the element points to a identity
for a different class type in schema.

eg.,
if there is an employee having an element for job which is part of a
different projection. The schema will have employee-type having
job-type's identity as reference. But to access the job object once
this schema is generated into a client proxy .cs file, to access the
job object for this employee, you need to go through all the jobs and
compare the identities of those with the identity in the employee
object.

I just want to have method called getJob() on employee which will do
this plumbing. My plan is to some how catalog all the objects coming in
and out through soap requests, something like having hashmap with
identity, object mapping. Implement methods which go to this hashmap
and get objects.

I dont know how much of this made sense, but this definitely requires
adding additional methods to classes generated using wsdl.exe. Even if
I can override this tool to trigger some events which I can catch and
add my own methods is also fine.

Ash, thanks for the link, will try to go through it and see whether its
useful for me.

Jul 21 '05 #3

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

Similar topics

10
by: Nikita A. Visnevski | last post by:
Hi everyone, I am rather new to Java beans. Just picked up a book last night and started reading about them. I am building an application that...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows...
2
by: Mark | last post by:
I have it in my head that I saw a marketing document from Microsoft with the total number of classes and methods in the .NET Framework. Something...
3
by: Kiran | last post by:
Hi, If I create a Virtual directory with application name programmatically it will not show up in the available web services while adding web...
1
by: Jeff Smith | last post by:
Can I load custom web user controls dynamically and access the properties and methods without having to explicitly define custom control types...
2
by: manohar.shankar | last post by:
Hi, I have been searching on this topic for quite sometime and didnt get any answer. Is there a way I can extend/add methods/properties to a C#...
3
by: rickeringill | last post by:
Hi comp.lang.javascript, I'm throwing this in for discussion. First up I don't claim to be any sort of authority on the ecmascript language spec...
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User...
3
by: Udi | last post by:
Hi All, I have an object that is reflected at runtime by Windows script host engine, so its public methods and properties can then be used from...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.