0

I have written a WCF web service which is being hosted in Windows Server 2012 through IIS-7. The server's public IP is currently open (the firewall is disabled). I can get the metadata and the wsdl document just fine with a browser, and I can add the service reference to Visual Studio through that IP. However, when my asp.net web page invokes a WCF service method, it gives me a 405 - Method Not Allowed error.

I think the problem is with cross-domain posting. I could be wrong, but that would make sense, since I only get errors when accessing the wcf service from an application.

How would I go about avoiding this issue?

Here is my Interface:

[ServiceContract]
public interface IDataPortalWCFService
{
    [OperationContract]
    string HelloWorldTest(string u, string p);

    [OperationContract]
    string HelloWorldTest2(string u, string p, string str);

    [OperationContract]
    string HelloWorldTest3(string u, string p);

    [OperationContract]
    DataTable GetBAQResults(string u, string p, string BAQName, DataTable BAQParameters);

    [OperationContract]
    string GetBAQResultsAsJSON(string u, string p, string BAQName, string BAQParameters);

}

1 Answers1

0

Dealing with cross domain headers when hosting a WCF service in IIS should be essentially the same as any other type of web site being hosted in IIS. The following question should help you find a solution...

CORS settings for IIS 7.5

Another way of solving this issue would be to simply reuse the domain.

e.g. for your web site use:-

www.mygreat.com

and for your api use

api.mygreat.com

Community
  • 1
  • 1
Mick
  • 6,527
  • 4
  • 52
  • 67