从 WCF 服务调用 webservice [英] Calling webservice from WCF service

查看:39
本文介绍了从 WCF 服务调用 webservice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从 WCF 服务使用 Web 服务 (c#.net) 时遇到问题.我得到的错误是 EndPointNotFoundException TCP 错误代码 10061:无法建立连接,因为目标机器主动拒绝它"

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"

我编写了一个单元测试来检查我是否可以向 Web 服务发送请求并且它运行良好[单元测试使用与我的 WCF 服务相同的绑定配置]

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]

Web 服务和 WCF 服务(客户端)具有基本的 http 绑定.

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

是否有人遇到过从 WCF 服务调用 Web 服务的类似问题?

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

服务模型部分如下

<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>

单元测试项目也使用相同的服务模型部分并且可以正常工作.唯一的问题是从另一个 WCF 服务调用该服务时.能否请您提出建议.

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.

推荐答案

你提到了webservice"和WCF service"——所以webservice"是一个老式的ASMX web service??

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

您的 WCF 服务是如何托管的?在 IIS 中?您是否有从 web.config 中的 WCF 调用的 Web 服务的必要端点信息?

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 ??

您能否向我们展示您的相关配置,例如<system.serviceModel> 部分您的 web.config(或 app.config,如果您自托管 WCF 服务),好吗?

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?

马克

这篇关于从 WCF 服务调用 webservice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆