none
WCF as IIS service : webHttpBinding RRS feed

  • Question

  • Hi,

    We have written a sample WCF service "console" application using webHttpBinding to have REST/JSON APIs.

    We now want to port the above as an IIS application.

    However,

    1. After having the IIS application, the GET/POST do not work.

    2. The Web.Config has webHttpBinding for the service.svc.
    The svcutil does not generates a config file, though it generates the client file.
    The client does not connect to the service.

    3. Now if we remove any sort of endpoint configuration from Web.config, the svcutil does generate the client
    code as well as the client configuration file with "basicHttpBinding".

    Now the client can talk to service by directly invoking the APIs.
    However, the GET/POST still does not work e.g. through a browser.

    Questions:

    1. Why does the IIS service does not work with "webHttpBinding" as an endpoint?

    2. Do we need some explicit handler in InetMgr for this kind of service? and if so, which Sytem.* one?

    3. Can I write the application as a Windows service and still expose it as an IIS application?

    We are using .NET 4.0.

    Thanks,

    Sahil

    Tuesday, October 27, 2015 10:20 AM

Answers

  • Hi Sahil Rangari,

    Are you sure your post url address is correctly?

    You can get the message from WCF Service, that means your service is hosted successfully.

    Are there have other error messages? Maybe you can set the following code on your web.config

    file to get more detailed  error messages. Like below:

    <serviceBehaviors>
            <behavior name="MsdnOAService.ServiceBehavior">
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
     

    Set includeExceptionDetailInFaults=True.

    Also, in my opinion is that you can use the fiddler to debug your WCF Service which you can put, get,

    delete, post.

    For more information, please refer to the following articles:

    1.Debug WCF REST Service.

    2.Testing and Monitoring WCF Service using soapUI and Fiddler

    Best Regards,

    Grady

    Thursday, October 29, 2015 9:22 AM
    Moderator

All replies

  • Hi Sahil Rangari,

    According to your description, I suggest you post one question in one thread.

    " Why does the IIS service does not work with "webHttpBinding" as an endpoint?">>

    Do you try host this service with self-host? and consume this service in a console application.

    Next, when we create the restful service, as far as I know we need not to generate the proxy class

    and config file.

    And do you configure the endpoint behavior in config file? like below:

    <endpointBehaviors>
            <behavior name="webHttpendBehavior">
              <webHttp/>
            </behavior>     
        </endpointBehaviors>

    For other question, I suggest you can create the new threads to post.

    For more information, please refer to the following articles:

    1.Hosting a WCF REST service on IIS

    2.A Beginner's Tutorial on How to Host a WCF Service (IIS Hosting and Self Hosting)

    Best Regards,

    Grady

    Wednesday, October 28, 2015 2:23 AM
    Moderator
  • Hi Grady,

    Thanks for the link (Hosting a WCF REST service on IIS).

    I had a URI template in the method declaration which was obstructing the call.

    Also, the configuration file (Web.config) didn't have all the data.

    I used the missing elements from the example and GET is working now.

    However, the POST is not working.
    I am using "Send HTTP Tool" to send a POST with "method" in the URI, but the tool
    reports that the "underlying connection was closed".

    I am using  EchoWithPost as the last element in the URI for the tool.

    Please guide me on the same.

    Appreciate it.

    Thanks,

    Sahil

    Wednesday, October 28, 2015 12:47 PM
  • Hi Sahil Rangari,

    Are you sure your post url address is correctly?

    You can get the message from WCF Service, that means your service is hosted successfully.

    Are there have other error messages? Maybe you can set the following code on your web.config

    file to get more detailed  error messages. Like below:

    <serviceBehaviors>
            <behavior name="MsdnOAService.ServiceBehavior">
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
     

    Set includeExceptionDetailInFaults=True.

    Also, in my opinion is that you can use the fiddler to debug your WCF Service which you can put, get,

    delete, post.

    For more information, please refer to the following articles:

    1.Debug WCF REST Service.

    2.Testing and Monitoring WCF Service using soapUI and Fiddler

    Best Regards,

    Grady

    Thursday, October 29, 2015 9:22 AM
    Moderator