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? 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?
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;
}
}
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; }
}
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
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". ???
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
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.
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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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
|
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
|
by: Shimon Sim |
last post by:
I have a custom composite control
I have following property
|
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
| |
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")
|
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,...
|
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,
…..
…..
}
|
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....
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |