views:

40

answers:

1

what is the URL for WCF post?

I create a VS 2008, WCF method like this

[WebMethod]
public string TestMethod(string param)
{
    return "param:" + param;
}

so then I go to

http://localhost:57000/Service1.asmx?op=TestMethod

But how do I do a post to this?

On the test page it says

HTTP POST

The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /Service1.asmx/TestMethod HTTP/1.1 Host: localhost Content-Type: application/x-www-form-urlencoded Content-Length: length

param=string

HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length

string

I would expect to be able to type in a url something like http://localhost:57000/Service1.asmx?op=TestMethod?param=teststring But that returns

Method 'TestMethod?param=teststring' was not found in service Service1.

What is the url to use to pass in a param to wcf or is it not possible or do I need to do something else to make it work

+1  A: 

I can't answer your specific question, but do you realize that "WebMethod" is an attribute from the .Net 1.1 library. I had to go look it up in the docs because I had never seen it before. That is definitely not WCF stuff.

From the error message you are getting, you need to put the parameter in a POST body and set the content type to application/x-www-form-urlencoded. You will need a tool like fiddler to do that.

You really should look into some of the newer libraries for doing web services stuff as what you are using is REALLY old. Search on the WebGet WebInvoke attributes to find newer HTTP web service facilities in WCF.

Darrel Miller
I was using VS 2008 and did a new ASP.net web service application.I am still trying to figure this out. Thanks for the help.
Maestro1024
Let me do you a favour before you start. If you are doing a quick and dirty web service, go look into the ASP.NET MVC framework. If you are looking at the beginning of a big web project, check out OpenRasta. You will thank me in 2 years. If you absolutely have to use WCF for some strange reason, go straight to .Net 4.0.
Darrel Miller