473,657 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web Service Soap extension , how set attribute

2 New Member
I try set soap extension attributes on client side. For example:

Implementation in web service:

Expand|Select|Wrap|Line Numbers
  1. [AttributeUsage(AttributeTargets.Method)]
  2. public class EncryptMessageAttribute : SoapExtensionAttribute
  3. {
  4. private string strKey="null";
  5.  
  6. public string StrKey
  7. {
  8. get {  return strKey; }
  9.  
  10. set { strKey = value; }    
  11. }
  12. }
  13.  
Soap extension class:

Expand|Select|Wrap|Line Numbers
  1. public class EncryptMessage : SoapExtension
  2. {
  3. ...
  4. }
  5.  
Used on web method:

Expand|Select|Wrap|Line Numbers
  1. [WebMethod]
  2. [EncryptMessage( StrKey = "pass")]
  3. public string test2()
  4. {
  5. return "ok";
  6. }
Implementation in Proxy class:

Expand|Select|Wrap|Line Numbers
  1. [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/test", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
  2. [EncryptMessage( StrKey = "pass")]
  3. public string test() {
  4. object[] results = this.Invoke("test", new object[0]);
  5. return ((string)(results[0]));
  6. }

Soap extension attributes are::[EncryptMessage( StrKey = "pass")]

I want set Soap Extension Attribute on client side, before than I use Soap Extension, when I call some web methods.

Example: I call some method, wich set soap extension attributes on both side, before than soap extension is used. Can somebody help me ?
Sep 9 '09 #1
1 4826
klerik123456
2 New Member
I have problem, I want set soap extension attribute in web method:
Soap extension in web service:

Expand|Select|Wrap|Line Numbers
  1. public class EncryptMessageAttribute : SoapExtensionAttribute
  2. {
  3. private string strKey="null";
  4.  
  5. public void  setKey(string s)
  6. {
  7. strKey=s;
  8. }
  9. }
Soap extension class:

Expand|Select|Wrap|Line Numbers
  1. public class EncryptMessage : SoapExtension
  2. {
  3. ....
  4. }

Soap extension on web method:

Expand|Select|Wrap|Line Numbers
  1. public class Service1 : System.Web.Services.WebService
  2. {
  3. public string k;
  4.  
  5. [WebMethod]
  6. [EncryptMessageAttribute(setKey(k))]
  7. public string test2()
  8. {
  9. return "ok";
  10. [WebMethod]
  11. [EncryptMessage(setKey(k))]
  12. public string test2()
  13. {
  14. return "ok";
  15. }
  16.  
  17. }

It finish with this compile error:

Error 1 The name 'setKey' does not exist in the current context
Error 2 An object reference is required for the non-static field, method, or property

Can somebody help me??
Sep 9 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2621
by: David | last post by:
Hi everyone, I wonder how is it possible to make PHP SOAP extension convert the returned complex type to an instance of one of my classes. Here I give you a short example: complexTest.wsdl: <?xml version="1.0" encoding="UTF-8"?>
1
5720
by: David C. allen | last post by:
I have created a simple Client-side SOAP Extension for a webclass that I have. When I apply the extension attribute to the the calling function in the proxy class I get an error 'Value cannot be null'. When the extension attribute is not applied it runs fine. The wierd thing is that it does not appear to be an error within the SOAP extension because I break-pointed it and when the proxy function gets called the SOAP extension runs fine....
3
7369
by: Dejan | last post by:
I was trying, for the first time, to create a (fairly simple) SOAP extension for some of my web services. They were to be called from the WindowsForms host application. Following error message occured: Client found response content type of '', but expected 'text/xml'. Calling this web service from the browser (as recommended) produced little more explanation:
4
6019
by: pepcag | last post by:
I used http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp as a template to create a very simple web method with soap extension. The code like this: public string HelloWorld() { return "Hello World.";
0
2933
by: Amar | last post by:
I am recieving the "The root element is missing" error from my soap extension while attempting to validate an incoming SOAP message request. I suspect the problem resides in the ChainStream method but I'm not sure. Below is a water-downed version of the code that I'm working on. While debugging, I noticed that if I pass an invalid SOAP request, the schema validation catches it and throws the error appropriately. However, when I pass in a...
4
6504
by: Ramon de Klein | last post by:
I have created a SOAP extension that can be enabled using a SoapExtensionAttribute. This attibute holds two additional properties that are used to configure the SOAP extension. This works fine, but I often want to use the SOAP extension from my web.config file and I have no idea how to configure it. The SOAP extension's GetInitializer method only receives the type of the webservice, but that isn't very useful for me. Adding the attribute...
0
1384
by: Robert Rotstein | last post by:
I want to write a SOAP extension that gets activated from both the client and the server. From whast I have read, this should be quite easy to do. Yet I can only activate it from the server. I have a service (.asmx file) which contains the following: namespace OfficerCallIn { public class OfficerCallInService :
0
1328
by: Robert Rotstein | last post by:
I want to write a SOAP extension that gets activated from both the client and the server. But so far, I have only been able to activate from the server. I have a service (.asmx file) which contains the following: namespace OfficerCallIn {
0
1986
by: Søren | last post by:
I have a web service with a SOAP extension loggin the SOAP. In the client's config file a <soapExtensionTypes> section is added and the SOAP extension is called as expected. Now the client is to be hosted by third party, and I want to be able to enable/disable the logging from the web.config of the web service. So I pasted the following into the web.config file (within the <system.web> section):
0
8384
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
8302
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
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
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
8601
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
5630
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
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.