Optional parameter in a <webmethod> attribute

Optional parameter in a <webmethod> attribute

Post by Saurab » Sun, 21 Apr 2002 06:46:39



I am writing a web service which would have an optional parameter at the
last.but when I give the optional parameter , the compiler throws backa
message saying that
 "Attribute 'WebMethod' cannot be applied to a method with optional
parameters."

Any solution to this problem ? Any comments wd be highly appreciated.

Thanks

Saurabh

 
 
 

Optional parameter in a <webmethod> attribute

Post by Scott Seel » Wed, 24 Apr 2002 02:52:12


You can document the parameter as optional. I believe that ASP.NET will pass
a null/nothing value if the parameter is missing. Your code would need to
check the value of the parameter.

--
***************************
This posting is provided "AS IS" with no warranties, and confers no rights.
***************************

Quote:> I am writing a web service which would have an optional parameter at the
> last.but when I give the optional parameter , the compiler throws backa
> message saying that
>  "Attribute 'WebMethod' cannot be applied to a method with optional
> parameters."

> Any solution to this problem ? Any comments wd be highly appreciated.

> Thanks

> Saurabh


 
 
 

Optional parameter in a <webmethod> attribute

Post by Saurabh » Wed, 24 Apr 2002 08:46:41


HI Scott
Thanks. But the ASP.NET webservice project does NOT compile at all if I
give an optional parameter for a function/procedure under <webmethod>
attribute.

Does this mean, there is no way to an optional parameter in a web
service call ?

Saurabh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  _alt.0
< 1K Download
 
 
 

Optional parameter in a <webmethod> attribute

Post by rames » Wed, 24 Apr 2002 09:27:27


You should look into using the "overloading" mechanism instead.

If you use overloading, you need to do something like the following for
e.g. -

<WebMethod(MethodName:="foo")> _
public function Foo() As String
end function

<WebMethod(MethodName:="foo1")> _
public function Foo(ByVal x As Int) As String
end function

ramesh


Quote:> HI Scott
> Thanks. But the ASP.NET webservice project does NOT compile at all if I
> give an optional parameter for a function/procedure under <webmethod>
> attribute.

> Does this mean, there is no way to an optional parameter in a web
> service call ?

> Saurabh

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

 
 
 

Optional parameter in a <webmethod> attribute

Post by Maarten van de Bospoo » Fri, 26 Apr 2002 02:23:46


C# does not have the concept of optional. VB does, but (although WSDL and
SOAP support it) the functionality is not implemented for webmethods.

Maarten
COM+/MTS support
EnterpriseServices Webservices and Remoting

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.

 
 
 

Optional parameter in a <webmethod> attribute

Post by Saurabh » Fri, 26 Apr 2002 02:43:12


Thanks. YOu answered my question.

Saurabh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  _alt.0
< 1K Download
 
 
 

Optional parameter in a <webmethod> attribute

Post by Alessandro Riol » Thu, 09 May 2002 07:56:05


Quote:> I am writing a web service which would have an optional parameter...
[zip]
> Any solution to this problem ?

Did polimorphism works for your problem?

int A(int a){...}
int A(int a, int b){...}

Ale

 
 
 

Optional parameter in a <webmethod> attribute

Post by Saurabh » Thu, 09 May 2002 08:11:21


AS far as I know, and my research goes , u cannot send an optional
parameter in an asp.net webservice.

but u can send a default value for that parameter , which May/May-Not
solve the purpose of optional parameters.

Saurabh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

Optional parameter in a <webmethod> attribute

Post by Renato Leandro Giulian » Wed, 11 Sep 2002 12:36:28


I was with this problem and I did this....

Observation: I used only string in my optional parameters

Example:

[WebMethod (EnableSession=true,Description="" )]

public int Sample(string Parameter1, string Parameter2)

{

    int A=0;

    int B=0;

    if (Parameter1 != "")

    {

        A = System.Convert.ToInt32(Parameter1);

    }

    if (Parameter2 != "")

    {

        B = System.Convert.ToInt32(Parameter2);

    }

    return A + B;

Quote:}

Renato Leandro Giuliana

MCP/MCSD

Brazil - SP

www.tba.com.br/


Quote:> I am writing a web service which would have an optional parameter at the
> last.but when I give the optional parameter , the compiler throws backa
> message saying that
>  "Attribute 'WebMethod' cannot be applied to a method with optional
> parameters."

> Any solution to this problem ? Any comments wd be highly appreciated.

> Thanks

> Saurabh

 
 
 

1. Immediare need for Hyperion resource <<<<<<<<<< sudheer_a@techwavenet.com >>>>>>>>>>>>


Hello Friends,

currently we have an immediate position for Hyperion Infrastructure resouce
fro the positio nin DAYTON OH, for 8+ months, if you have any one for the
position, send me the resume along with the contact details and the
rate.... please respond

*Hyperion_Infrastructure/Hyperion IR Infrastructure Resource*

Location: Dayton, OH

Start:  11/28

Duration:  8+ months

Rate: Open

*Upgrading HPSU ver 8.5 to IR ver 11.1.1.3.*

install and migrate

*Sudheer*| Techwave Consulting Inc**

*O: *484.252.2741 |484.222.2027| F: 484.872.8716


YIM & GTalk: sudheer.staffing

Business Intelligence Experts**

This email including its attachments, has confidential and privileged
information for the use of intended recipients only . Any review,
retransmission, dissemination or other use of, or taking of any action in
reliance upon this information by persons or entities other than the
intended recipient is prohibited. If you received this email in error,
please delete all copies of the original message from your system and
contact the sender immediately. All documents and/or messages that include
'an electronic sound, symbol, or process, attached to or logically
associated with a record and executed or adopted by a person with the
intent to sign the record', originating from, sent or received
electronically, via this email address will be considered as bearing the
sender's electronic signature under UETA: Uniform Electronic Transactions
Act. (1999)

2. Exchange: have a new Palm VII, want a Compaq Aero 15x0 or 21x0

3. SAP APO Direct client Immediate need <<<<<<<< sudheer_a@techwavenet.com >>>>>>>>>>>>

4. Psion Teklogix Advertising NetPad

5. Direct client SAP SD Vistex immediate position <<<<<<<< sudheer_a@techwavenet.com >>>>>>>>

6. Inserting Audio in FP

7. <<<< Error Reading Files >>>>

8. prog fails when run twice

9. DataSet<=>XML<=>XSL<=>HTML<=>EXCEL

10. Web control for <ul><li></li></ul>

11. <Web Controls><Web Controls2></Web Controls2></Web Controls>

12. Grid: ItemCreated add attribute to <input>, not <td> on client side?

13. <<< Cannot index table >>>