4

I have a web service that provides two interfaces. One is "MyAppNameData" and the other is "MyAppNameSync". I am adding two service references to a WPF application. In the code, when I use "MyAppNameData" reference, I don't get an error. When I use "MyAppNameSync" the following error is generated:

Could not find default endpoint element that references contract 'MyAppNameSync.IMyAppNameSync' 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 contract could be found in the client element.

I added the two references in the exact same way but, MyAppNameData was added using BasicHttpBinding and MyAppNameSync was added with WSHttpBinding. I don't know why that is the case.

Here is the serviceModel element from the client's app.config file. As you can see, there is an endpoint element that references the contract 'MyAppNameSync.IMyAppNameSync', contrary to what the error message says:

    <system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IMyAppNameData" 
                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>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IMyAppNameSync" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" 
                hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" 
                 maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" 
                     proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" 
                    negotiateServiceCredential="true"
                        algorithmSuite="Default" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://computername.domainname.home/MyAppNameSyncService/MyAppNameData.svc"
            binding="basicHttpBinding" 
            bindingConfiguration="BasicHttpBinding_IMyAppNameData"
            contract="MyAppNameData.IMyAppNameData" 
            name="BasicHttpBinding_IMyAppNameData" />
        <endpoint address="http://computername.domainname.home/MyAppNameSyncService/MyAppNameSync.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyAppNameSync"
            contract="MyAppNameSync.IMyAppNameSync" 
            name="WSHttpBinding_IMyAppNameSync">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>       
</system.serviceModel>

Any recommendations would really be appreciated.

Thanks

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
rogdawg
  • 687
  • 3
  • 11
  • 33
  • What do you mean by adding both references in the same way? You should need add only one reference and it should create both proxies. – Ladislav Mrnka Sep 21 '11 at 10:55
  • Thank you for your response. The web service I published has two .svc files in it. MyAppNameData.svc and MyAppNameSync.svc. To add the service references, I right-click the Service References node, choose add, one of the svc files, give it a Namespace name, and click OK. I do the same again for the other svc file. – rogdawg Sep 21 '11 at 12:19
  • Ok I'm sorry I thought you have a single service with two endpoints but you have two unrelated services. – Ladislav Mrnka Sep 21 '11 at 12:31
  • 1
    Does it work with just the single `wsHttpBinding`? And does it work if you switch the `wsHttpBinding` to a `basicHttpBinding`? Basically, can you figure out if it's the `wsHttpBinding` syntax causing the problem, or if it's having multiple bindings causing the problem? – Rachel Sep 21 '11 at 14:16
  • Yesterday I tried to change the app.config file so that both bindings were basicHttpBinding. I still continued to get the error. I have moved the sync functionality into MyAppNameData.svc, and rebuilt the web service, removing MyAppNameSync.svc completely. So, now I am binding to only one .svc file. I don't like this because the sync functionality really is separate from the other functionality but, it is working now. There are still several questions I would like answered regarding this issue so, I don't want to mark this "fixed", even though I am working past it now. Thanks for responding – rogdawg Sep 21 '11 at 16:02
  • OK. I really need an answer to this. I am sure that the way I am attempting to structure this application is the way that I "should" be doing it. But, I cannot make it work. Is there anyone that can help me with this? – rogdawg Sep 27 '11 at 17:45
  • 2
    It doesn't look like you tried Rachel's full suggestion. Are you able to reference just `MyAppNameSync`. Until then, you won't know if the problem is with the binding or if it's the double binding. – sellmeadog Sep 27 '11 at 22:34

1 Answers1

2

OK. I have it working now. I apparently had several errors going at the same time. As Rachel suggested in her comment above, I tried to get a simplest case working. But, was initially unable to. Removing one of the services from the host, so I only had MyAppNameData.svc did not, initially, work. I knew the simple version of the web service worked in the past so, I tried to get everything back to that working point.

I used one of my existing ASP.NET web applications to point to the instance of the web service that I have been using for testing, and I was able to get that to work (even while having two services; MyAppNameData.svc and MyAppNameSync.svc in the host MyAppNameWebService). So, I knew that the problem was between my WPF application and the web service.

I had seen several discussion threads that stated "This error can arise if you are calling the service in a class library and calling the class library from another project". But, I thought I had accounted for that issue in my problem solving steps. But, when I stripped everything out of my WPF project, and rebuilt it all (for the 100th time), making sure "to include the WS configuration settings into the main projects app.config if its a winapp or web.config if its a web app" as stated in this thread, I was able to get it to work!

I had attempted this solution before but, apparently I had still not resolved some other issue. I am no longer getting the error, and I am able to connect to, and use, the two separate services from the same host. So, I am in business.

Thank you all for your responses and suggestions. Now, on to other challenges!

Community
  • 1
  • 1
rogdawg
  • 687
  • 3
  • 11
  • 33