I´m having problem consuming a WCF Service.
To call this Service, I created my own WCF Service with VS2008 own template.
Then I added a Service Reference to the WCF Service to consume.
So far so good, the service shows up in the Solution Explorer and all
methods as well.
Then I Created a Class to call the Service from my own WCF Service.
And everytime I try to create an object I get the same error message.
"Could not find default endpoint element that references contract ‘IService’
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 tried all suggested solutions found on the web without success. The
web.config file shows the correct naming and URL of the WCF service I am
trying to call.
As a side note, creating a service reference and calling the WCF service
from a WinForm app works perfectly. Basically I need to do this from a class
library.
How can I make this work???
Since the class is in a DLL a "class library", you need a app.config in
the classlib project that has the WCF client side configuration 'end
points', just like any other WCF client.
The WCF service you're talking about is not the client to the WCF
service you're trying to call. And there should be no WCF client side
configuration information in the Web.config used by the WCF Web service.
The WCF client is the class in the classlib project, and the classlib
project needs an app.config with the client side WCF endpoints. The
app.config is not there (not found).
From your description, you're encountering some endpoint configuration not
found error when trying to consume a WCF service in your own WCF project,
correct?
As for your own WCF project, is it a class library project or console or
web project? Generally, for client application that need to call WCF
service, we first create the client service proxy class through VS Add
ServiceReference or svcutil.exe, then using the generated proxy class to
invoke service operations. And when creating the service proxy classes, the
tool will also add configuration entries for the WCF service and endpoints
in app.config file. If you are generating the service proxy in a class
library project(not winform or console that will output executable image),
you need to manually merge the app.config content into the actual
application's app.config(in which you will reference the class library that
contains the WCF service proxy).
For your scenario, I suggest you first try generating the WCF service proxy
in a normal console project and call it to see whether it works. If it
works, the target service should be ok, and we can continue to look into
the client project that behaves incorrectly.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
--------------------
From: =?Utf-8?B?S2FpIEZyYW5zc29u?= <kfra...@nospam.nospam>
Subject: how to call wcf service from another wcf service or class library?
Date: Wed, 27 Jan 2010 06:22:02 -0800
Hi!
I´m having problem consuming a WCF Service.
To call this Service, I created my own WCF Service with VS2008 own template.
Then I added a Service Reference to the WCF Service to consume.
So far so good, the service shows up in the Solution Explorer and all
methods as well.
Then I Created a Class to call the Service from my own WCF Service.
And everytime I try to create an object I get the same error message.
"Could not find default endpoint element that references contract
‘IService�?
We have verified that the WCF service works correctly. It is easy to add a
service reference to it from a Winform app, and call its methods.
I however, want to call this WCF service from a class library. This class
library is invoked by another class library, which in turn in invoked by an
asmx-webservice, hosted in IIS.
I try to illustrate the components below. Framework version inside
parenthesis.
Asmx web-app (2.0 with WSE)
|
Class library 1 (3.5)
|
Class library 2 (3.5) --------> WCF service
How should I go about to accomplish this (manually merging code sounds
really awkward to me)? I thought it was just to add a service reference from
class library 2 and GO, but apprantly it is very complicated for some reason.
I would really appreciate help with this!
Regards
Kai
""Steven Cheng"" wrote:
> I´m having problem consuming a WCF Service.
> To call this Service, I created my own WCF Service with VS2008 own template.
> Then I added a Service Reference to the WCF Service to consume.
> So far so good, the service shows up in the Solution Explorer and all
> methods as well.
>
> Then I Created a Class to call the Service from my own WCF Service.
> And everytime I try to create an object I get the same error message.
>
> "Could not find default endpoint element that references contract
> ‘IService�
So the WCF service itself is ok and it can be consumed directly in a client
application(such as console or winform).
Now, I'm thinking that the problem is due to the configuration elements(of
the WCF client endpoints) that is not correctly copied into the client
application's app.config file.
When you create a WCF client proxy through "Add ServiceReference", you can
find that it will also generate some configuraiton elements in the
app.config file(no matter what kind of project you're using---- console or
winform or class library), correct? These configuration elements need to
be copied to the final client application which will use the generated WCF
client proxy classes. For your scenario, that client application is the
Asmx webservice application because it calles classlib1 and classlib calles
classlib2 which contains the WCF client proxy. Therefore, you need to copy
the WCF related configuraiton elements from the app.config generated in
class library 2 project into your ASMX webservice project's web.config file.
BTW, I notice that you said the ASMX web-app is configured with .NET 2.0.
Is the IIS server .NET 3.X enabled? You need to make sure the asmx web
application environment is .NET 3.X enabled, otherwise, you will not be
able to use any .NET 3.x components such as WCF.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
--------------------
From: =?Utf-8?B?S2FpIEZyYW5zc29u?= <kfra...@nospam.nospam>
References: <B8B81C86-8D39-4A63...@microsoft.com>
<o1Hlyu#nKHA...@TK2MSFTNGHUB02.phx.gbl>
Subject: RE: how to call wcf service from another wcf service or class libr
Date: Thu, 28 Jan 2010 04:45:01 -0800
Hi!
We have verified that the WCF service works correctly. It is easy to add a
service reference to it from a Winform app, and call its methods.
I however, want to call this WCF service from a class library. This class
library is invoked by another class library, which in turn in invoked by an
asmx-webservice, hosted in IIS.
I try to illustrate the components below. Framework version inside
parenthesis.
Asmx web-app (2.0 with WSE)
|
Class library 1 (3.5)
|
Class library 2 (3.5) --------> WCF service
How should I go about to accomplish this (manually merging code sounds
really awkward to me)? I thought it was just to add a service reference
from
class library 2 and GO, but apprantly it is very complicated for some
reason.
I would really appreciate help with this!
Regards
Kai
""Steven Cheng"" wrote:
> Hi,
>
> From your description, you're encountering some endpoint configuration
not
> found error when trying to consume a WCF service in your own WCF project,
This probably solves your issue.
> On Wednesday, January 27, 2010 9:22 AM Kai Fransson wrote:
> Hi!
>
> I??m having problem consuming a WCF Service.
> To call this Service, I created my own WCF Service with VS2008 own template.
> Then I added a Service Reference to the WCF Service to consume.
> So far so good, the service shows up in the Solution Explorer and all
> methods as well.
>
> Then I Created a Class to call the Service from my own WCF Service.
> And everytime I try to create an object I get the same error message.
>
> "Could not find default endpoint element that references contract ???IService???
> 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 tried all suggested solutions found on the web without success. The
> web.config file shows the correct naming and URL of the WCF service I am
> trying to call.
>
> As a side note, creating a service reference and calling the WCF service
> from a WinForm app works perfectly. Basically I need to do this from a class
> library.
>
> How can I make this work???
>> On Wednesday, January 27, 2010 11:42 PM Mr. Arnold wrote:
>> Kai Fransson wrote:
>>
>> Since the class is in a DLL a "class library", you need a app.config in
>> the classlib project that has the WCF client side configuration 'end
>> points', just like any other WCF client.
>>
>> The WCF service you are talking about is not the client to the WCF
>> service you are trying to call. And there ishould be no WCF client side
>> configuration information in the Web.config used by the WCF Web service.
>>
>> The WCF client is the class in the classlib project, and the classlib
>> project needs an app.config with the client side WCF endpoints. The
>> app.config is not there (not found).
>>> On Thursday, January 28, 2010 2:29 AM stchen wrote:
>>> ------=_NextPart_0001_650C4BF3
>>> Content-Type: text/plain
>>> Content-Transfer-Encoding: 7bit
>>>
>>> Hi,
>>>
>>> From your description, you are encountering some endpoint configuration not
>>> found error when trying to consume a WCF service in your own WCF project,
>>> correct?
>>>
>>> As for your own WCF project, is it a class library project or console or
>>> web project? Generally, for client application that need to call WCF
>>> service, we first create the client service proxy class through VS Add
>>> ServiceReference or svcutil.exe, then using the generated proxy class to
>>> invoke service operations. And when creating the service proxy classes, the
>>> tool will also add configuration entries for the WCF service and endpoints
>>> in app.config file. If you are generating the service proxy in a class
>>> library project(not winform or console that will output executable image),
>>> you need to manually merge the app.config content into the actual
>>> application's app.config(in which you will reference the class library that
>>> contains the WCF service proxy).
>>>
>>> For your scenario, I suggest you first try generating the WCF service proxy
>>> in a normal console project and call it to see whether it works. If it
>>> works, the target service should be ok, and we can continue to look into
>>> the client project that behaves incorrectly.
>>>
>>> Sincerely,
>>>
>>> Steven Cheng
>>>
>>> Microsoft MSDN Online Support Lead
>>>
>>>
>>> Delighting our customers is our #1 priority. We welcome your comments and
>>> suggestions about how we can improve the support we provide to you. Please
>>> feel free to let my manager know what you think of the level of service
>>> provided. You can send feedback directly to my manager at:
>>> msd...@microsoft.com.
>>>
>>> ==================================================
>>> Get notification to my posts through email? Please refer to
>>> http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
>>>
>>>
>>> --------------------
>>> From: =?Utf-8?B?S2FpIEZyYW5zc29u?= <kfra...@nospam.nospam>
>>> Subject: how to call wcf service from another wcf service or class library?
>>> Date: Wed, 27 Jan 2010 06:22:02 -0800
>>>
>>>
>>> Hi!
>>>
>>> I??m having problem consuming a WCF Service.
>>> To call this Service, I created my own WCF Service with VS2008 own template.
>>> Then I added a Service Reference to the WCF Service to consume.
>>> So far so good, the service shows up in the Solution Explorer and all
>>> methods as well.
>>>
>>> Then I Created a Class to call the Service from my own WCF Service.
>>> And everytime I try to create an object I get the same error message.
>>>
>>> "Could not find default endpoint element that references contract
>>> ???IService???
>>> 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 tried all suggested solutions found on the web without success. The
>>> web.config file shows the correct naming and URL of the WCF service I am
>>> trying to call.
>>>
>>> As a side note, creating a service reference and calling the WCF service
>>> from a WinForm app works perfectly. Basically I need to do this from a
>>> class
>>> library.
>>>
>>> How can I make this work???
>>>
>>> ------=_NextPart_0001_650C4BF3
>>> Content-Type: text/x-rtf
>>> Content-Transfer-Encoding: 7bit
>>>
>>> {\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}{\f1\fswiss\fprq2\fcharset134 System;}}
>>> \viewkind4\uc1\pard\lang2052\f0\fs20 Hi,
>>> \par
>>> \par From your description, you are encountering some endpoint configuration not found error when trying to consume a WCF service in your own WCF project, correct?
>>> \par
>>> \par As for your own WCF project, is it a class library project or console or web project? Generally, for client application that need to call WCF service, we first create the client service proxy class through VS Add ServiceReference or svcutil.exe, then using the generated proxy class to invoke service operations. And when creating the service proxy classes, the tool will also add configuration entries for the WCF service and endpoints in app.config file. If you are generating the service proxy in a class library project(not winform or console that will output executable image), you need to manually merge the app.config content into the actual application's app.config(in which you will reference the class library that contains the WCF service proxy).
>>> \par
>>> \par For your scenario, I suggest you first try generating the WCF service proxy in a normal console project and call it to see whether it works. If it works, the target service should be ok, and we can continue to look into the client project that behaves incorrectly.
>>> \par
>>> \par Sincerely,
>>> \par
>>> \par Steven Cheng
>>> \par
>>> \par Microsoft MSDN Online Support Lead
>>> \par
>>>> On Thursday, January 28, 2010 7:45 AM Kai Fransson wrote:
>>>> Hi!
>>>>
>>>> We have verified that the WCF service works correctly. It is easy to add a
>>>> service reference to it from a Winform app, and call its methods.
>>>>
>>>> I however, want to call this WCF service from a class library. This class
>>>> library is invoked by another class library, which in turn in invoked by an
>>>> asmx-webservice, hosted in IIS.
>>>>
>>>> I try to illustrate the components below. Framework version inside
>>>> parenthesis.
>>>>
>>>> Asmx web-app (2.0 with WSE)
>>>> |
>>>> Class library 1 (3.5)
>>>> |
>>>> Class library 2 (3.5) --------> WCF service
>>>>
>>>> How should I go about to accomplish this (manually merging code sounds
>>>> really awkward to me)? I thought it was just to add a service reference from
>>>> class library 2 and GO, but apprantly it is very complicated for some reason.
>>>> I would really appreciate help with this!
>>>>
>>>> Regards
>>>> Kai
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ""Steven Cheng"" wrote:
>>>>> On Wednesday, February 03, 2010 1:21 AM stchen wrote:
>>>>> ------=_NextPart_0001_83B40142
>>>>> Content-Type: text/plain
>>>>> Content-Transfer-Encoding: 7bit
>>>>>
>>>>> Hi Kai,
>>>>>
>>>>> So the WCF service itself is ok and it can be consumed directly in a client
>>>>> application(such as console or winform).
>>>>>
>>>>> Now, I am thinking that the problem is due to the configuration elements(of
>>>>> the WCF client endpoints) that is not correctly copied into the client
>>>>> application's app.config file.
>>>>>
>>>>> When you create a WCF client proxy through "Add ServiceReference", you can
>>>>> find that it will also generate some configuraiton elements in the
>>>>> app.config file(no matter what kind of project you are using---- console or
>>>>> winform or class library), correct? These configuration elements need to
>>>>> be copied to the final client application which will use the generated WCF
>>>>> client proxy classes. For your scenario, that client application is the
>>>>> Asmx webservice application because it calles classlib1 and classlib calles
>>>>> classlib2 which contains the WCF client proxy. Therefore, you need to copy
>>>>> the WCF related configuraiton elements from the app.config generated in
>>>>> class library 2 project into your ASMX webservice project's web.config file.
>>>>>
>>>>> BTW, I notice that you said the ASMX web-app is configured with .NET 2.0.
>>>>> Is the IIS server .NET 3.X enabled? You need to make sure the asmx web
>>>>> application environment is .NET 3.X enabled, otherwise, you will not be
>>>>> able to use any .NET 3.x components such as WCF.
>>>>>
>>>>> Sincerely,
>>>>>
>>>>> Steven Cheng
>>>>>
>>>>> Microsoft MSDN Online Support Lead
>>>>>
>>>>>
>>>>> Delighting our customers is our #1 priority. We welcome your comments and
>>>>> suggestions about how we can improve the support we provide to you. Please
>>>>> feel free to let my manager know what you think of the level of service
>>>>> provided. You can send feedback directly to my manager at:
>>>>> msd...@microsoft.com.
>>>>>
>>>>> ==================================================
>>>>> Get notification to my posts through email? Please refer to
>>>>> http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
>>>>>
>>>>>
>>>>> --------------------
>>>>> From: =?Utf-8?B?S2FpIEZyYW5zc29u?= <kfra...@nospam.nospam>
>>>>> Subject: RE: how to call wcf service from another wcf service or class libr
>>>>> Date: Thu, 28 Jan 2010 04:45:01 -0800
>>>>>
>>>>>
>>>>> Hi!
>>>>>
>>>>> We have verified that the WCF service works correctly. It is easy to add a
>>>>> service reference to it from a Winform app, and call its methods.
>>>>>
>>>>> I however, want to call this WCF service from a class library. This class
>>>>> library is invoked by another class library, which in turn in invoked by an
>>>>> asmx-webservice, hosted in IIS.
>>>>>
>>>>> I try to illustrate the components below. Framework version inside
>>>>> parenthesis.
>>>>>
>>>>> Asmx web-app (2.0 with WSE)
>>>>> |
>>>>> Class library 1 (3.5)
>>>>> |
>>>>> Class library 2 (3.5) --------> WCF service
>>>>>
>>>>> How should I go about to accomplish this (manually merging code sounds
>>>>> really awkward to me)? I thought it was just to add a service reference
>>>>> from
>>>>> class library 2 and GO, but apprantly it is very complicated for some
>>>>> reason.
>>>>> I would really appreciate help with this!
>>>>>
>>>>> Regards
>>>>> Kai
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ""Steven Cheng"" wrote:
>>>>>
>>>>> not
>>>>> application
>>>>>>> On Friday, March 26, 2010 12:51 PM Mike Lovell wrote:
>>>>>>> http://www.gotinker.com/2010/03/09/minimal-wcf-serverclient-without-app-config/
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Mike
>>>>>>> GoTinker, C# Blog
>>>>>>> http://www.gotinker.com
>>>>>>> Submitted via EggHeadCafe
>>>>>>> .NET Windows Services - Timer, Debugging, and Installation
>>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/0ddb1434-d3c9-424c-8b12-bdf75c50588c/net-windows-services--timer-debugging-and-installation.aspx