Board index » Web Programming » webservice and method decoration

webservice and method decoration

Web Programming75
hi there,



i'm a newbie in this field and i hope i'm not asking a very stupid

question, but googling i didn't find my way out of here.



what i want to do is to write a method, export it through a webservice

in such a way that the result is sent back to the caller in a

compressed way (the soap header remains uncompressed, but the body of

the soap message is compressed). so i followed the instructions here:



www.mastercsharp.com/article.aspx



and it's easy to understand what it does. at least i think so. the

problem is a step further. let's say i export the webmethod:



[WebMethod,CompressionExtension]

public string foo_method(...)

{

...

}



at the address http://localhost/mywebservice.asmx . now, if i try to

create a proxy for my webservice through the:



c:\>wsdl http://localhost/mywebservice.asmx?wsdl



command, what i get is a (auto-generated) class containing a (auto-

generated) method:



[WebMethod]

public string foo_method(...)

{

...

}



this means that invokin the foo_method() from my proxy, i get an error

because the result is compressed while proxy expects it to be

uncompressed. so what i do is to modify the proxy method manually

adding the CompressionExtension.



the question is: how can i do in order to let wsdl to auto-generate

also the [CompressionExtension] decoration? in this way i can make

faster (and "batchable") my development and deployment phases. i hope

i was able to explain my trouble.



thank you in advantage for any hint you can give to me :)



have a nice day



francesco


-
 

Re:webservice and method decoration

"Francesco Spegni" <francesco.spegni@gmail.com>wrote in message

Quote
hi there,



i'm a newbie in this field and i hope i'm not asking a very stupid

question, but googling i didn't find my way out of here.



what i want to do is to write a method, export it through a webservice

in such a way that the result is sent back to the caller in a

compressed way (the soap header remains uncompressed, but the body of

the soap message is compressed). so i followed the instructions here:



http://www.mastercsharp.com/article.aspx?ArticleID" rel="nofollow" target="_blank">www.mastercsharp.com/article.aspx=86&TopicID=7



and it's easy to understand what it does. at least i think so. the

problem is a step further. let's say i export the webmethod:



[WebMethod,CompressionExtension]

public string foo_method(...)

{

...

}



at the address http://localhost/mywebservice.asmx . now, if i try to

create a proxy for my webservice through the:



c:\>wsdl http://localhost/mywebservice.asmx?wsdl



command, what i get is a (auto-generated) class containing a (auto-

generated) method:



[WebMethod]

public string foo_method(...)

{

...

}





You should not be getting a [WebMethod] attribute on your proxy methods.

What command line did you use in the WSDL command?

--

John Saunders [MVP]





-

Re:webservice and method decoration



Quote
You should not be getting a [WebMethod] attribute on your proxy methods.

What command line did you use in the WSDL command?



oops, you're right i said a wrong thing: what i really get is

something like:



/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://

attiweb/Autentica", RequestNamespace="http://attiweb/",

ResponseNamespace="http://attiweb/",

Use=System.Web.Services.Description.SoapBindingUse.Literal,



ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

public CoppiaOfInt32String[] Autentica(string strUserCredentials)

{

object[] results = this.Invoke("Autentica", new object[] {

strUserCredentials});

return ((CoppiaOfInt32String[])(results[0]));

}



where "Autentica" is the name of my webmethod and "http://attiweb" is

the namespace of my webservice. it remains the problem: i would like

to prepose the method signature with something like:



[System.Web.Services.Protocols.SoapDocumentMethodAttribute(...),CompressionExtension]

... rest of the method signature...



is that possible in some way?



to answer your question: the command i use is:



c:\>wsdl http://localhost/mywebservice.asmx?wsdl



(as i specified in my first message).



thanx



-

Re:webservice and method decoration

"Francesco Spegni" <francesco.spegni@gmail.com>wrote in message

Quote


>You should not be getting a [WebMethod] attribute on your proxy methods.

>What command line did you use in the WSDL command?



oops, you're right i said a wrong thing: what i really get is

something like:



/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://

attiweb/Autentica", RequestNamespace="http://attiweb/",

ResponseNamespace="http://attiweb/",

Use=System.Web.Services.Description.SoapBindingUse.Literal,



ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

public CoppiaOfInt32String[] Autentica(string strUserCredentials)

{

object[] results = this.Invoke("Autentica", new object[] {

strUserCredentials});

return ((CoppiaOfInt32String[])(results[0]));

}



where "Autentica" is the name of my webmethod and "http://attiweb" is

the namespace of my webservice. it remains the problem: i would like

to prepose the method signature with something like:



[System.Web.Services.Protocols.SoapDocumentMethodAttribute(...),CompressionExtension]

... rest of the method signature...



Francesco,



I haven't tried this, but I believe that you can configure SOAP extensions

in the configuration file of your client application, the same way you can

for a web service application.



There is a more general mechanism, which will work for .NET clients, but is

more involved. See "Walkthrough: Customizing the Generation of Service

Descriptions and Proxy Classes" at

msdn2.microsoft.com/en-us/library/x4s9z3yc(vs.80).aspx.">msdn2.microsoft.com/en-us/library/x4s9z3yc(vs.80).aspx.

--

John Saunders [MVP]





-