Reputation: 171
I am facing strange issue.
I have one WCF Library that is calling one external wcf service. and i am able to see the result as expected in test client.
But i have to host this WCF Library in IIS, for that i have to use one wcf service. I refered Wcflibrary dll into the service, but getting the below error while creating object to external wcf service.
An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll but was not handled in user code
Additional information: Could not find default endpoint element that references contract 'SMSAgent.SMSGatewayPort' 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.
can any body please suggest.Is this scenario is having any issues?
Upvotes: 1
Views: 4425
Reputation: 31750
There is no technical reason why you can't call a WCF service from another WCF service. You can chain as many service calls together as you like.
Let's call your calling service ServiceA and the external service ServiceB.
The error you are getting is saying that there is a problem with the client configuration in ServiceA. What this means is that the code telling WCF how to construct the client channel from ServiceA to ServiceB is missing or invalid.
Now, for each service you want to call, you need to define an endpoint inside the client section in your <system.serviceModel/>
configuration. Your endpoint definition must specify:
Optionally, you may need to include a service identity specification, depending on if the service you're calling requires authentication.
For example:
<client>
<endpoint name="MyExternalEndpoint"
address="http://externalservice.com"
binding="wsHttpBinding"
contract="ExternalService.IServiceContract" >
<identity>
<dns value="externalservice.com" />
</identity>
</endpoint>
</client>
Upvotes: 2