473,657 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't get my custom attribute from web method

I've added my custom attribute to a web service's method. When I
consume the web service and attempt to check the value of the attribute,
it's not there, but the WebMethod attribute is. My attribute descends
from the same System.Attribut e class as the WebMethod attribute does.

Can anyone tell me why it has gone missing?
Nov 23 '05 #1
9 4572
Post the code of the attribute and WebMethod.

Bye.

"Brad Wood" wrote:
I've added my custom attribute to a web service's method. When I
consume the web service and attempt to check the value of the attribute,
it's not there, but the WebMethod attribute is. My attribute descends
from the same System.Attribut e class as the WebMethod attribute does.

Can anyone tell me why it has gone missing?

Nov 23 '05 #2
Andrea Laperuta wrote:
Post the code of the attribute and WebMethod.


// This is the web method. Results are the same whether
// I decorate it with a WebMethod attribute or not.
[StringAttribute ("blah")]
public string getResultCode()
{
return mResult;
}

// StringAttribute is my custom attribute that I have used many times:
public class StringAttribute : System.Attribut e
{
private string mString;
public StringAttribute (string s): base()
{
mString = s;
}
public override string ToString()
{
return mString;
}
}

// I use this method to get the value of the StringAttribute passing
// the web service object and the method name "getResultCode" .
// This works fine in all other instances including from within
// the web service itself.
// When I debug through this code, obj contains a
// WebMethod attribute when I add that additional attribute,
// but not my StringAttribute .
public static string getAttribValue( Object obj, string memberName)
{
// I presume this is an array to account for overloaded methods...
MemberInfo[] mi = obj.GetType().G etMember(member Name);
if ( mi.Length > 0 )
{
foreach( MemberInfo currentMI in mi )
{
Attribute ca = Attribute.GetCu stomAttribute(c urrentMI,
typeof(StringAt tribute));
if ( ca != null )
{
return attrToString( ca );
}
}
return string.Empty;
}
else
{
return string.Empty;
}

}
Nov 23 '05 #3
Sorry for the long time you waited, but I was busy, however I tried your
code and I have to tell you that works fine on my pc!

I think that the problem isn't in the code.

Let me now if you have more clues...

Bye.

"Brad Wood" wrote:
Andrea Laperuta wrote:
Post the code of the attribute and WebMethod.


// This is the web method. Results are the same whether
// I decorate it with a WebMethod attribute or not.
[StringAttribute ("blah")]
public string getResultCode()
{
return mResult;
}

// StringAttribute is my custom attribute that I have used many times:
public class StringAttribute : System.Attribut e
{
private string mString;
public StringAttribute (string s): base()
{
mString = s;
}
public override string ToString()
{
return mString;
}
}

// I use this method to get the value of the StringAttribute passing
// the web service object and the method name "getResultCode" .
// This works fine in all other instances including from within
// the web service itself.
// When I debug through this code, obj contains a
// WebMethod attribute when I add that additional attribute,
// but not my StringAttribute .
public static string getAttribValue( Object obj, string memberName)
{
// I presume this is an array to account for overloaded methods...
MemberInfo[] mi = obj.GetType().G etMember(member Name);
if ( mi.Length > 0 )
{
foreach( MemberInfo currentMI in mi )
{
Attribute ca = Attribute.GetCu stomAttribute(c urrentMI,
typeof(StringAt tribute));
if ( ca != null )
{
return attrToString( ca );
}
}
return string.Empty;
}
else
{
return string.Empty;
}

}

Nov 23 '05 #4
Where are you trying to check for this Attribute? If its in the proxy
you will not find it there

Brad Wood wrote:
Andrea Laperuta wrote:
Post the code of the attribute and WebMethod.


// This is the web method. Results are the same whether
// I decorate it with a WebMethod attribute or not.
[StringAttribute ("blah")]
public string getResultCode()
{
return mResult;
}

// StringAttribute is my custom attribute that I have used many times:
public class StringAttribute : System.Attribut e
{
private string mString;
public StringAttribute (string s): base()
{
mString = s;
}
public override string ToString()
{
return mString;
}
}

// I use this method to get the value of the StringAttribute passing
// the web service object and the method name "getResultCode" .
// This works fine in all other instances including from within
// the web service itself.
// When I debug through this code, obj contains a
// WebMethod attribute when I add that additional attribute,
// but not my StringAttribute .
public static string getAttribValue( Object obj, string memberName)
{
// I presume this is an array to account for overloaded methods...
MemberInfo[] mi = obj.GetType().G etMember(member Name);
if ( mi.Length > 0 )
{
foreach( MemberInfo currentMI in mi )
{
Attribute ca = Attribute.GetCu stomAttribute(c urrentMI,
typeof(StringAt tribute));
if ( ca != null )
{
return attrToString( ca );
}
}
return string.Empty;
}
else
{
return string.Empty;
}

}


--
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Nov 23 '05 #5
Dilip Krishnan wrote:
Where are you trying to check for this Attribute? If its in the proxy
you will not find it there


I don't understand the question, "If its in the proxy
you will not find it there". ???
Nov 23 '05 #6
If you try to check the web service attributes in a web service proxy
class you will not find it there. Web service proxy class is the class
that you use to call methods on a web service. Usually has the same name
as the service and can be created by "Adding web reference..."

Brad Wood wrote:
Dilip Krishnan wrote:
Where are you trying to check for this Attribute? If its in the proxy
you will not find it there


I don't understand the question, "If its in the proxy
you will not find it there". ???


--
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Nov 23 '05 #7
Dilip Krishnan wrote:
If you try to check the web service attributes in a web service proxy
class you will not find it there.


That's not true; as I mentioned, the WebMethod attribute is present in
the proxy object and my custom attribute was present in past builds.
Nov 23 '05 #8
Hello Brad,

Are you sure you had a WebMethod attribute in your proxy? I would seriously
doubt that

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Dilip Krishnan wrote:
If you try to check the web service attributes in a web service proxy
class you will not find it there.

That's not true; as I mentioned, the WebMethod attribute is present in
the proxy object and my custom attribute was present in past builds.


Nov 23 '05 #9
Dilip Krishnan wrote:
Hello Brad,

Are you sure you had a WebMethod attribute in your proxy? I would
seriously doubt that

When I programmaticall y search through the attribute collection of my
proxy object (from my test harness), I do in fact find the
WebMethodAttrib ute object in there. And I am quite certain that I
*used* to find my custom attribute as well, but I was using Delphi.net
at the time, so it undoubtedly created the proxy dll differently.

BTW, where the heck is the proxy dll? Is it buried in the framework
folders? I can't find it.
Nov 23 '05 #10

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

Similar topics

3
1821
by: F. Da Costa | last post by:
Hi, I was wondering *why* there is a difference between the results of the following two statements. On the suface they seem to do the same (or do they?) frm => returns void frm.getAttribute("custom") => returns the value of the attribute
1
1822
by: Tim Smith | last post by:
I have a large number of methods across different classes accessed via remoting. Every time a method is executed I would like to update a status object - keeping count of the number of method executions. Is this possible using a custom attribute or is there an alternate method? thanks
3
3856
by: Ryan Moore | last post by:
I am trying to "tune" some user controls in ASP.NET for optimal caching. Is it possible to do a vary by param - on a Session Variable, so the page caches when a Session variable stays the same, but refreshes when the session changes? thnx
7
2989
by: Shimon Sim | last post by:
I have a custom composite control I have following property
15
2143
by: Jeff Mason | last post by:
Hi, I'm having a reflection brain fog here, perhaps someone can set me on the right track. I'd like to define a custom attribute to be used in a class hierarchy. What I want to do is to have an attribute which can be applied to a class definition of a class which inherits from a base, mustinherit class. I want to define methods in the base class which will access the contents of the attribute as it is applied to
6
9381
by: Peter Hartlén | last post by:
Hi! What's the correct syntax for the default value design time attribute, using classdiagram view and Custom Attributes dialog. For a boolean: DefaultValue(true) DefaultValue("true") DefaultValue("bool","true")
1
3800
by: andy_from_fl | last post by:
I created a custom business object from the ground up- I applied the data binding interfaces, coded every property by hand, custom constructors, the whole deal. I wanted the columns to appear in a default order, so I made my own TypeDescriptor and TypeDescriptionProvider and made that provider the default by an attribute at the class level. As soon as I added that attribute, my Sql Client reportviewer control wouldn't dispaly any data,...
2
2290
by: filipk69 | last post by:
Could someone point me in the right direction, please. I have an enum something like this: enum TextFieldType { FieldABC = 3000, FieldXYZ = 3001, ….. ….. }
4
6809
by: =?Utf-8?B?QWJoaQ==?= | last post by:
I am using Reflection to invoke methods dynamically. I have got a special requirement where I need to pass a value to method by setting the custom method attribute. As I cannot change the signature of method to pass a new parameter, I am setting the custom attribute of a given method and then accessing the attribute from method. Since attribute value is decided at runtime I want to change the attribute of particular method at runtime....
0
8385
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
8303
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
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
8502
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,...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
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.