none
wsHttpBinding mode not giving any responce when access from .svc RRS feed

  • Question

  • Hi,

    I have created WCF service, which can be consumed by SharePoint BCS functionality.

    The service exposes metadata, but when we call functions from .svc then it wont be called and obviously service not giving any output.

    Code is as below:

    [ServiceContract]
        public interface IEmployeeServices
        {
            [OperationContract]
            void DoWork();

            [OperationContract]
            [WebGet(ResponseFormat=WebMessageFormat.Xml)]
            List<EmployeeInfo> GetAllEmployees();
        }

    public class EmployeeServices : IEmployeeServices
        {
            public void DoWork()
            {
            }

            /// <summary>
            /// Return the list of employees
            /// </summary>
            /// <returns></returns>
            public List<EmployeeInfo> GetAllEmployees()
            {
                EmployeeDBEntities dbentities = new EmployeeDBEntities();

                return dbentities.EmployeeInfoes.ToList();
            }
        }

    Web config

    <system.serviceModel>
        <diagnostics>
          <messageLogging logEntireMessage="true"
                          logMalformedMessages="false"
                          logMessagesAtServiceLevel="false"
                          logMessagesAtTransportLevel="true"
                          maxMessagesToLog="3000"
                          maxSizeOfMessageToLog="2000"/>
        </diagnostics>

        <bindings>
          <wsHttpBinding>
            <binding name="wshttpbind"  allowCookies="true" closeTimeout="00:01:00"
            receiveTimeout="00:01:00" maxReceivedMessageSize="2048" maxBufferPoolSize="2048" >
              <security mode="None"></security>
            </binding>
          </wsHttpBinding>
        </bindings>
        <services>
          <service name="WcfService_BCS.EmployeeServices" behaviorConfiguration="soapBehavior">
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wshttpbind" contract="WcfService_BCS.IEmployeeServices" bindingName="wshttpbind">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>

        <behaviors>
          <serviceBehaviors>
            <behavior name="soapBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"
                policyVersion="Default" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" />
          <add binding="wsHttpBinding" scheme="http" />

        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
            <listeners>
              <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\logs\Traces.svclog"/>
            </listeners>
          </source>
        </sources>
      </system.diagnostics>

    And I am calling url as

    http://localhost:59441/EmployeeServices.svc/GetAllEmployees

    But the URL doesn't giving any response, the function is not getting called if I put debug in the code as well.

    Kindly let me know the solution, so that the service will return the response.

    Regards,

    Uday


    mahajan

    Thursday, January 14, 2016 12:46 PM

Answers

  • Hi udayan,

    According to this case, based on your code, you want to create a Restful WCF Service, so

    you haveto use the webhttpbinding. For this issue, when you use the wsHttpbinding,

    the service is SOAP style. So, you don't need to use the WebGet attribute. So, I am not

    sure which way do you want to use.

    If you want to create a Restful WCF service, please refer this links:

    1.A Guide to Designing and Building RESTful Web Services with WCF 3.5

    2.How to: Create a Basic WCF Web HTTP Service

    If you want to create a general WCF service, please refer to the following links:

    1.WCF Getting Started Tutorial

    Best Regards,

    Wanjun Dong


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.


    Friday, January 15, 2016 6:52 AM
    Moderator

All replies