3

I created a "Ajax enabled WCF service". I can consume the service from javascript code and the WebService works as intended. But, I want to write ATP's around it. So, I am adding the webservice as a "Service Reference" into my ATP Project. Then I am using calling the webservice as usual. It all compiles fine. But when I run the ATP, it throws me back this error

"System.InvalidOperationException : Could not find endpoint element with name 'ServiceReference1.IWCFService' and contract 'ServiceReference1.IWCFService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element."

This is what I have in my App.config file of the ATP.

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IWCFService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://yashworkspace/BSS/WS/ServiceReference1.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFService"
            contract="ServiceReference1.IWCFService" name="BasicHttpBinding_IWCFService" />
    </client>
<services>
    <service name="ServiceReference1.WCFService">
        <endpoint address="http://yashworkspace/BSS/WS/ServiceReference1.svc" behaviorConfiguration="org.proj.WebServices.WCFServiceAspNetAjaxBehavior"
                binding="webHttpBinding" contract="org.proj.WebServices.IWCFService" />
    </service>
</services>
<behaviors>
    <endpointBehaviors>
        <behavior name="org.proj.WebServices.WCFServiceAspNetAjaxBehavior">
            <enableWebScript />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
    </serviceBehaviors>
</behaviors>
</system.serviceModel>

Please let me know what could have gone wrong?? I have a normal WCF Service and that is working totally fine.

Please help.

regards Yash

2 Answers 2

1

The above answer from Drew Marsh is partially right. But the main issue is solved as follows. Additionally, Here the issue is, when u expose the WCF as a ajax enabled WCF service, it communicates using JSON. When you are calling the same service from a C# code, it called it using a SOAP request. So you need to configure your service such that it accepts both JSON and SOAP requests. So, in the services section, you need to configure it as follows

<services>
      <service name="ServiceReference1.WCFService">
          <endpoint address="" behaviorConfiguration="org.proj.WebServices.WCFServiceAspNetAjaxBehavior"
            binding="webHttpBinding" contract="org.proj.WebServices.IWCFService"  />
          <endpoint address="soapreq" behaviorConfiguration="org.proj.WebServices.MyServiceSOAPBehaviour" bindingConfiguration="BasicHttpBinding_IUpdateService"
                  binding="basicHttpBinding" contract="org.proj.WebServices.IWCFService" name="ServiceReference1.IWCFService" />
      </service>
  </services>

In the behaviors section, you need to configure your endpoint behaviors as follows..

<endpointBehaviors>
          <behavior name="org.proj.WebServices.WCFServiceAspNetAjaxBehavior">
              <enableWebScript />
          </behavior>
          <behavior name="org.proj.WebServices.MyServiceSOAPBehaviour">
          </behavior>
      </endpointBehaviors>
Sign up to request clarification or add additional context in comments.

1 Comment

You actually don't have to communicate using SOAP from C#. You can change the client binding to use the webHttpBinding as well which will cause it to communicate the same way using JSON.
0

The problem is the name of the endpoint does not match what the client instance is looking for:

<endpoint address="http://yashworkspace/BSS/WS/ServiceReference1.svc" 
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFService" 
        contract="ServiceReference1.IWCFService" name="BasicHttpBinding_IWCFService" /> 

According to the error message it expects the name to also be "ServiceReference1.IWCFService" so you this is the endpoint you would need.

<endpoint address="http://yashworkspace/BSS/WS/ServiceReference1.svc" 
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFService" 
        contract="ServiceReference1.IWCFService" name="ServiceReference1.IWCFService" /> 

1 Comment

Your answer is partially right. Thanks. Atleast it showed me a way to debug things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.