none
Can't do a GET call of a WCF method RRS feed

  • Question

  • Hi all,

    I'm trying to call this simple WCF method via GET (with querystring) in the web browser:

    [OperationContract]
    [WebGet(UriTemplate = "/foo/{value}")]
    int foo(int value);

    In the Web.config of the application i put the following:

    <service name="GeoWebService.GeoService" behaviorConfiguration="GetBehavior">
                    <endpoint address="" binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="GeoWebService.IGeoService">
                    </endpoint>
    </service>
    ...
    <behavior name="WebBehavior">
        <webHttp/>
    </behavior>

    The problem is that I get this error (relative to <webHttp/>):

    Warning 1 The element 'behavior' has invalid child element 'webHttp'. List of possible elements expected: 'serviceAuthorization, serviceCredentials, serviceMetadata, serviceSecurityAudit, serviceThrottling, dataContractSerializer, serviceDebug, serviceTimeouts, persistenceProvider, workflowRuntime'.

    How can I fix this? I'm using Visual Studio 2008 and .NET framework 3.5.

    Thank you very much for your time.

    • Moved by Lisa Zhu Monday, November 5, 2012 6:40 AM wcf related (From:Visual C# General)
    Thursday, November 1, 2012 6:42 PM

Answers

  • Hi Antonio,

    Please note the "WebBehavior" should be an endpoint behavior:

      <system.serviceModel>
        <services>
          <service name="GeoWebService.GeoService" behaviorConfiguration="GetBehavior">
            <endpoint address="" binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="GeoWebService.IGeoService">
            </endpoint>
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>        
            <behavior name="WebBehavior">
              <webHttp/>
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="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="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    If this is not your case, please let me know. Thanks.

    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, November 5, 2012 8:59 AM
    Moderator

All replies

  • First off, remove the <webHttp/> tag from within the <behavior> tag. 

        <behavior name="WebBehavior">

        </behavior>

    Saturday, November 3, 2012 11:34 PM
  • Hi Antonio,

    From your description , I ‘d like to move this post to  the most related forum for better support.

    You may have more luck getting answers .

    Thanks for your understanding .

    Regards ,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, November 5, 2012 6:40 AM
  • Hi Antonio,

    Please note the "WebBehavior" should be an endpoint behavior:

      <system.serviceModel>
        <services>
          <service name="GeoWebService.GeoService" behaviorConfiguration="GetBehavior">
            <endpoint address="" binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="GeoWebService.IGeoService">
            </endpoint>
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>        
            <behavior name="WebBehavior">
              <webHttp/>
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="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="false"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
    If this is not your case, please let me know. Thanks.

    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, November 5, 2012 8:59 AM
    Moderator