List parameters of the Web Service

H

hulkko123

Hello,

Is it possible to list parameters and their types when you are using
[WebMethod (Description ()] tag or any else tag?

I couldn't find any lineseparator characters to Description attribute
when I was trying
to list parameters in hardcoded way. All parameters came is one big
line.

So, how should I list Web Methods parameteters if I like to show them
to user?
Such situations are e.g. when user or programmer pressed F5 or ctrl-F5
in Visua Studio
when the Web Service project is open and (s)he want to test Web
Service.

Any ideas?

Cheers!
 
J

Josh Twist

Hello,

I'm not sure I understand your question... If your WebMethod has
parameters - you'd be able to see them right there in the code?

[WebMethod]
public string SayHello(string name)
{
return "Hello" + name;
}

They's also be visible in the WSDL and help page generated by ASP.NET
(browse to your .asmx page to see the help page, click Service
Description to see the WSDL).

Josh
http://www.thejoyofcode.com/
 
S

Simon Hart

If you mean when navigating to the .ASMX page using a browser, then append
?wsdl on the end.

Simon Hart.
 
H

hulkko123

"Problem" occurs usually when we have multisuplier projects.
Documents are usually not yet updated and we have to use other vendors
Web service methods.
It would help a lot if we would know what kind of parameter Web Service
methods excatly wants.
That would also help application programmers when they call these
methods.
Every method of course checks it parameters before it's executes so,
knowing what kind of parameter
a Service wants would help a lot (less error calls).
E.g. information considering parameters could be format, length, sets
that are valid etc. and that would help a lot.
Something like this:

[WebMethod]
[Attribute Param1 = "[0-9]{5}"]
[Attribute Param2 = "[A-Z]{10}"]
[Attribute Param3 = "(ABC)|(DEF)|(GHI)"]
public string WSMethod(string param1, string param2, string param3 ...
)
{
// Logic coded here
}

I don't know the syntax for this Attribute but that is the actual
question.

Cheers!
 
H

hulkko123

Yep, that shows the wsdl but if there is business kind of rules for
parameter values
wsdl doesn't seems to help.. or are there any ways to do it using wsdl?

Cheers!
 
S

Simon Hart

Sorry I don't follow, business rules? do you mean documentation for
parameters, if so I don't know of any way. Web services are supposed to be
self describing.

Simon Hart.
 
G

Guest

So what is "self descriping"? That is the main question. That is missing
often.
Think about e.g. Identity number of the person in Air field.
Clerk is behind desk and a foreign passanger comes.
Clerk needs to know the format of the foreign passanger.
Ok, application tells to that clerk the rigth format but the programmer
of that application must know the excat format of the Identity number that
belongs to passanger depending his/hers nationality.

How can a programmer validate it? (S)he must just know it precisely. Like I
said
in multivendor projects documentation is quite often poor so a "self
descriping"
Web Service would offer the right format by showing the format that it
expects.

What I mean is that it would be nice that C# Web Service would show to
programmer
what kind (format) parameters is wants. This is how we cut down Web Service
calls that has
parameters in wrong format.

In e.g VS.NET by pressing F5 it would be nive if we could inform the excat
format of parameters that
that Service wants, not only name of the parameter.

Am I makíng myself more clear now?

Cheers!
 
J

Josh Twist

The WSDL is how Web Services are self describing. The WSDL contains
information that can be read by other computers including:

The endpoint (url) of the web service
The names of methods available in the service
The names of parameters
and... information about the type of parameters and return types

It's important to note that Web Services do not share Type they share
contract (or schema) - what that means is that the WSDL contains a
representation of your Types that can be understood by any programming
language that can interpret WSDL. It's what makes web services
interoperable.

Josh
http://www.thejoyofcode.com/
 
S

Simon Hart

OK. So I take it you have maybe a string field or a predefined type and it
has to be in a particular format.

One way you could offer help to the programmer by the means of in-line
documentation:

/// <summary>

/// Posts the current transaction data currently held in local stack
relevant to the passed

/// terminal ID.

/// </summary>

/// <param name="termID">The terminal identifier, not be greater than 10
bytes</param>

[WebMethod (Description="Posts the passed terminal identifier data into
Equator")]

public void Post(string termID)

{

}



Something like the above will work through intellisense.

Simon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top