[ACCEPTED]-WCF Service Returning "Method Not Allowed-web-services

Accepted answer
Score: 75

If you are using the [WebInvoke(Method="GET")] attribute on the service 5 method, make sure that you spell the method 4 name as "GET" and not "Get" or "get" since 3 it is case sensitive! I had the same error 2 and it took me an hour to figure that one 1 out.

Score: 66

Your browser is sending an HTTP GET request: Make 2 sure you have the WebGet attribute on the 1 operation in the contract:

[ServiceContract]
public interface IUploadService
{
    [WebGet()]
    [OperationContract]
    string TestGetMethod(); // This method takes no arguments, returns a string. Perfect for testing quickly with a browser.

    [OperationContract]
    void UploadFile(UploadedFile file); // This probably involves an HTTP POST request. Not so easy for a quick browser test.
 }
Score: 4

The basic intrinsic types (e.g. byte, int, string, and 20 arrays) will be serialized automatically 19 by WCF. Custom classes, like your UploadedFile, won't 18 be.

So, a silly question (but I have to 17 ask it...): is UploadedFile marked as a 16 [DataContract]? If not, you'll need to make sure that 15 it is, and that each of the members in the 14 class that you want to send are marked with 13 [DataMember].

Unlike remoting, where marking 12 a class with [XmlSerializable] allowed you 11 to serialize the whole class without bothering 10 to mark the members that you wanted serialized, WCF 9 needs you to mark up each member. (I believe 8 this is changing in .NET 3.5 SP1...)

A tremendous 7 resource for WCF development is what we 6 know in our shop as "the fish book": Programming WCF Services by 5 Juval Lowy. Unlike some of the other WCF 4 books around, which are a bit dry and academic, this 3 one takes a practical approach to building 2 WCF services and is actually useful. Thoroughly 1 recommended.

Score: 2

I ran into this exact same issue today. I 3 had installed IIS, but did not have the 2 activate WCF Services Enabled under .net 1 framework 4.6.

enter image description here

Score: 1

It sounds like you're using an incorrect 4 address:

To access the Service I enter http://localhost/project/myService.svc/FileUpload

Assuming 3 you mean this is the address you give your 2 client code then I suspect it should actually 1 be:

http://localhost/project/myService.svc
Score: 1

I've been having this same problem for over 6 a day now - finally figured it out. Thanks 5 to @Sameh for the hint.

Your service is probably 4 working just fine. Testing POST messages 3 using the address bar of a browser won't 2 work. You need to use Fiddler to test a 1 POST message.

Fiddler instructions... http://www.ehow.com/how_8788176_do-post-using-fiddler.html

Score: 0

Only methods with WebGet can be accessed 4 from browser IE ; you can access other http 3 verbs by just typing address

You can either 2 try Restful service startup kit of codeples 1 or use fiddler to test your other http verbs

Score: 0

you need to add in web.config

<endpoint address="customBinding" binding="customBinding" bindingConfiguration="basicConfig" contract="WcfRest.IService1"/>  

<bindings>  
    <customBinding>  
        <binding name="basicConfig">  
            <binaryMessageEncoding/>  
            <httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864"/>  
        </binding>  
    </customBinding> 

0

Score: 0

My case: configuring the service on new 2 server. ASP.NET 4.0 was not installed/registered 1 properly; svc extension was not recognized.

More Related questions