views:

619

answers:

2

I am having an issue consuming a webservice (c#.net) from a WCF service. The error i am getting is EndPointNotFoundException "TCP error code 10061: No connection could be made because the target machine actively refused it"

I wrote a unit test to check if i could send a request to the web service and it worked fine [The unit test is using the same binding configuration as my WCF service]

The web service and WCF service (client) have basichttp binding.

Did anyone had similar kind of issue calling a webservice from a WCF service?

The service Model section is as follows

<system.serviceModel>
 <bindings>
  <basicHttpBinding>
   <binding name="DataService" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:05: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://10.22.33.67/Service/DataService.asmx" binding="basicHttpBinding" 
            bindingConfiguration="DataService" contract="Service.DataService" name="DataService"/>
 </client>
 <services>
  <service name="TestToConsumeDataService.WCFHost.Service1" behaviorConfiguration="TestToConsumeDataService.WCFHost.Service1Behavior">
   <!-- Service Endpoints -->
   <endpoint address="" binding="basicHttpBinding" contract="TestToConsumeDataService.WCFHost.IService1">
    <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
    <identity>
     <dns value="localhost"/>
    </identity>
   </endpoint>
   <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
 </services>
 <behaviors>
  <serviceBehaviors>
   <behavior name="TestToConsumeDataService.WCFHost.Service1Behavior">
    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
    <serviceMetadata httpGetEnabled="true"/>
    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
    <serviceDebug includeExceptionDetailInFaults="false"/>
   </behavior>
  </serviceBehaviors>
 </behaviors>
</system.serviceModel>

The unit test project is also using the same service model section and it works. The only issue is while calling the service from another WCF service. Could you please suggest.

+1  A: 

You mentioned "webservice" and "WCF service" - so the "webservice" is a old-style ASMX web service??

How is your WCF service hosted? In IIS? Do you have the necessary endpoint information for the webservice you're calling from WCF inside your web.config ??

Can you show us your relevant configs, e.g. the <system.serviceModel> section of your web.config (or app.config, if you're self-hosting the WCF service), please?

The error means there's either no webservice listening at the address you're using, or you don't have access rights to it. Are you missing some security or something?

MArc

marc_s
Hi, I think its something to do with security. The nunits are working fine since it runs under my windows user account. Is there a way i can configure my WCF service to use the windows credentials when it calls the other service? The end point configuration use by nunit and WCF srevice are same.
Balaji
That's why I was asking: what does your config look like? What kind of authentication does the remote webservice expect?
marc_s
I have added the config section, could you please have a quick look and suggest if the settings are incorrect?
Balaji
@Balaji: ok, you're not using any security at all - now the question is: does the webservice you're calling expect / require any kind of security / authentication? Right now, the WCF service will not supply anything at all.....
marc_s
Yes the webservice i am calling requires authentication, passing my windows credentials should work. The Nunit works since it uses my windows login details. I am not able to figure out how do i pass the details when i call the service from a WCF client. Could you please put some light in this?
Balaji
A: 

It looks like there is some configuration that you need to call your web service.

  • This configuration is correct in the configuration file of your unit test.
  • But it is not correct or missing in the configuration file of your WCF service.

When you have two dll's where one calls the other, then it is the config file of the first dll that is used. However, when you go over a WCF hop, it is the config file of the WCF service that takes over.

Hope this helps

Shiraz

Shiraz Bhaiji