.net - How to run WCF service method with WebGet attribute on the root of the host -
.net - How to run WCF service method with WebGet attribute on the root of the host -
i have wcf service contract:
[servicecontract] public interface ipolicyretriever { [operationcontract, webget(uritemplate = "/clientaccesspolicy.xml")] stream getsilverlightpolicy(); } with web.config section:
<service behaviorconfiguration="policyretrieverservicebehavior" name="webservice.policyretriever"> <endpoint address="" binding="webhttpbinding" behaviorconfiguration="policyretrieverendpointbehavior" contract="webservice.ipolicyretriever" /> </service> the server running on localhost, visual studio web hosting, on port 8080 , web service file named webservice.svc.
the above code create getsilverlightpolicy() method exposed on http://localhost:8080/webservice.svc/clientaccesspolicy.xml.
what need expose file on root of webserver instead of webservice.svc sub-path, not find way accomplish this.
setting endpoint address property / or http://localhost:8080/ did not work.
neither adding host section service node:
<host> <baseaddresses> <add baseaddress="http://localhost:8080/"/> </baseaddresses> </host> did find solution?
you can accomplish shown below:
set wcf project back upwards aspnetcompatiblitymode true shown below:
<servicehostingenvironment aspnetcompatibilityenabled="true" /> now open code behind (class implements interface) , add together next attribute above service class:
[aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.required)] now open global.asax if have 1 (else add together one) , in application_start method add together next line:
routetable.routes.add(new serviceroute("", new webservicehostfactory(), typeof(restservice))); you can rid of svc file now. 1 time above steps build project , deploy iis. url of web service
http://localhost/virtualdirectoryname/clientaccesspolicy.xml .net wcf wcf-binding webget
Comments
Post a Comment