简体   繁体   中英

Deploying WCF Web Service from File System to IIS

Is there anything special i need to do to deploy this service in IIS, right now I publish the site to the file system from visual studio then created the application in IIS.

I can browse to the .svc file in my web browser but i cant call any of the operations.

This is the Web.config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>     
      <wsHttpBinding>
        <binding name="wsHttpBinding" openTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00"
          maxBufferPoolSize="9223372036854775807" maxReceivedMessageSize="9223372036854775807">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None" />
          <reliableSession enabled="true" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors >
        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="MerlonWebServiceAPI.MGWS">
        <endpoint address="" behaviorConfiguration="" binding="wsHttpBinding" bindingNamespace="http://SingleWSDL/MGWS"
          bindingConfiguration="" name="wsHttp" contract="MerlonWebServiceAPI.IService" >
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />       
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>  
</configuration>

This is the IService

[ServiceContract(Namespace = "http://SingleWSDL/MGWS")]
public interface IService
{
    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "ActiveCalls")]
    List<ActiveCall> GetActiveCalls();

    [OperationContract]
    [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "PointStatus")]
    List<PointStatus> GetPointStatus();

    [OperationContract]
    bool Validate(string username, string password);
}

I can dump the full wsdl file if required thanks in advance for any assistance

Sometimes you need to just adjust the app Pool for the "Web Site" you have deployed to look at the correct framework. In my case it is almost always V2, whereas I require to change it to V4.

You did not write how are you trying to access the service. Do you use WCF Test Client? If so then it should work when you add service url. Test client will show you all methods exposed by wsHttpBinding.

But if you are trying to make a http REST call to the service, there is no endpoint listening. You should also expose webHttpBinding endpoint. I have not tested it but this should do

<endpoint address="rest" binding="webHttpBinding" bindingNamespace="http://SingleWSDL/MGWS" bindingConfiguration="" name="restHttp" contract="MerlonWebServiceAPI.IService" />

Then you could access it typing http://{serviceurl}/rest/ . Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM