Calling a Web Service from a WCF Service

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

I wrote a unit test to check if I can send a request to a web service and it worked fine [unit test uses the same binding configuration as my WCF service]

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

Has anyone had a similar question calling a web service from a WCF service?

The Service Model section looks like this

<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 also uses the same section of the service model and it works. The only issue is calling the service from another WCF service. Could you please suggest.

+2


source to share


2 answers


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

How is your WCF service hosted? In IIS? Do you have the required endpoint information for the web service you are calling from WCF inside your web.config ??

Can you show us the relevant settings for example. section of <system.serviceModel>

your web.config (or app.config if you own the WCF service) please?



An error means that you either do not listen to the web service at the address you are using, or you do not have permission to access it. Are you missing some kind of security or something?

pomace

+1


source


It looks like there is some kind of configuration that needs to be called on the web service.

  • This config is correct in your unit test config file.
  • But this is incorrect or missing from your WCF service config file.

When you have two dlls where you call the other, then this is the config file of the first dll that is used. However, when you go to the WCF host, the WCF service config file responds.



Hope it helps

Shiraz

0


source







All Articles