views:

1314

answers:

3

This seems like a simple question, but I haven't been able to find the answer online via many Google searches. I have a C# web service and, when I visit its ASMX page in the browser, for a particular method it always has the following:

"The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values."

Likewise for SOAP 1.2 and HTTP POST. What I want to know is how I replace the placeholders shown, which are things like:

<myParameter>string</myParameter>

Where 'string' is the placeholder. And in the response:

<xsd:schema>schema</xsd:schema>xml

Where 'schema' and 'xml' are the placeholders. I've been using another web service that has these placeholders filled out with example values for the parameters and responses, and I would like to define such examples for my own web methods, too. I was able to describe the entire method with the following:

[WebMethod(Description="Does awesome things.")]

But I have not found such a thing for the individual parameters of a web method.

A: 

Why would you want to do that? That page you see in the browser when hitting your asmx is just giving sample requests and reponses. If you want to get data using those examples, replace the placholder values in the request with what you are querying from the service, and POST to it...

Edit: I mean, if you really need to replace those placholder values, write code in your service to determine when someone does a GET (implying viewing from a browser), and play with the response, changing the placeholder values to whatever you require.

Janie
A: 

You can't do it. If the help page (which is what you're describing) does not have an input box for a particular parameter, then it means it doesn't know how to do that.

You should not pay too much attention to those pages in any case. They go away with WCF.

They were never of very much use anyway, except for the simplest web services. They were a way to get people into the web service game way back in the beginning when there were no tools to help you test a web service. Use soapUI instead.


BTW, also see Microsoft: ASMX Web Services are a “Legacy Technology” for why it makes good sense to ignore ASMX-only pages.

John Saunders
+3  A: 

By default DefaultWsdlHelpGenerator.aspx is called to generate the "help" page. You can set another (or modified) template with the wsdlHelpGenerator Element in your web.config file.

VolkerK