My first WCF client, fails with exception: "Could not find endpoint element with name blah blah etc."

I'm building a windows form application in VS 2008 (C#). It needs to connect to a 3rd party webservice (http://www.NIJobs.com/WebService/JobTags.asmx) to download some tags that will be used to populate a UI control in the form.

I added a Service Reference to my forms project.

And I created the proxy in my Form like this....

            // get popular tags from webservice... populate tags member...
            String[] saTags;
            using (JobTagsHttpPostClient wsClient = new JobTagsHttpPostClient("JobTagsSoap"))
            {
                saTags = wsClient.GetPopularCategoryTags("8"); // IT is category 8?
            }

Open in new window


but the creation of the proxy object is failing with:

Could not find endpoint element with name 'JobTagsSoap' and contract 'NIjobsJobTags.JobTagsHttpPost' 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.

I've been hunting online for a solution and I've seen that a lot of people were getting this error. However I haven't seen a definitive solution yet.

It seems that VS 2008 forgot to create a tiny part of the plumbing when setting this up....
zorba111Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Duy PhamFreelance IT ConsultantCommented:
You should use JobTagsSoapClient instead of JobTagsHttpPostClient with endpoint configuration name "JobTagsSoap". Like below:

            String[] saTags;
            using (JobTagsSoapClient wsClient = new JobTagsSoapClient("JobTagsSoap"))
            {
                saTags = wsClient.GetPopularCategoryTags("8"); // IT is category 8?
            }

Open in new window

1
zorba111Author Commented:
Yes, I had got it working earlier by using JobTagsSoapClient instead of JobTagsHttpPostClient as a client object.

But I wanted to use the JobTagsHttpPostClient because I understand HTTP POST and I don't know the SOAP protocol yet.

Its all to do with the app.config file, and understanding what the elements mean. For a WCF client the element is <client/>.

<client>
  <endpoint address="http://www.nijobs.com/WebService/JobTags.asmx"
      binding="basicHttpBinding" bindingConfiguration="JobTagsSoap"
      contract="NIjobsJobTags.JobTagsSoap" name="JobTagsSoap" />
  <!--endpoint address="http://www.nijobs.com/WebService/JobTags.asmx"
       binding="basicHttpBinding" 
       contract="NIjobsJobTags.JobTagsHttpPost" name="JobTagsHttpPost" /-->
  <endpoint address="http://www.nijobs.com/WebService/JobTags.asmx"
      binding="customBinding" bindingConfiguration="JobTagsSoap12"
      contract="NIjobsJobTags.JobTagsSoap" name="JobTagsSoap12" />
</client>

Open in new window


After reading up a bit more, I stated editing the endpoints.

In the endpoint I was editing (commented out) I cut the other attributes out to focus on the basic ABC - address, binding (the protocol/transport), contract (the class that implements the "interface"). To use the JobTagsHttpPostClient, i had to make sure the contract was set to: "NIjobsJobTags.JobTagsHttpPost". I wasn't sure what to do about the "name" attribute so I changed it.

I was able to instantiate the JobTagsHttpPostClient this time, but I got an exception on the first method call.

If it ain't broke don't fix it...so I just gave up and went back to using JobTagsSoapClient :)

When/if I have more time I'll read up more on the configuration options - the ABCs. Shame the IDE doesn't get this right. Maybe its a good thing as it forces people to lift the bonnet and get their hands dirty.

Onwards...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zorba111Author Commented:
Its a workaround, rather than tackling the real reason why I can't get JobTagsHttpPostClient to work.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WCF

From novice to tech pro — start learning today.