首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >WCF -从另一个Web应用程序(WCF或REST API)调用时的EndpointNotFoundException

WCF -从另一个Web应用程序(WCF或REST API)调用时的EndpointNotFoundException
EN

Stack Overflow用户
提问于 2021-02-23 13:21:55
回答 1查看 36关注 0票数 0

最近,我在WCF中从另一个Web应用程序(WCF或REST API)调用时遇到了EndpointNotFoundException的问题。

我正在尝试连接到外部WCF服务,这需要登录和密码识别(目前我正在由供应商准备的测试环境)。

然后异常出现:

There was no endpoint listening at https://xxx/yyy.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details

这个问题不会出现在控制台应用程序中-工作流畅,但只有当我创建简单的项目时,如WCF或REST API。

代码语言:javascript
运行
复制
<bindings>
      <customBinding>
        <binding name="custom">
          <security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport"
            requireDerivedKeys="true" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings detectReplays="false" />
            <localServiceSettings detectReplays="false" />
          </security>
          <textMessageEncoding messageVersion="Soap11WSAddressing10" />
          <httpsTransport maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"/>
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="https://uslugaterytws1test.stat.gov.pl/TerytWs1.svc"
        binding="customBinding" bindingConfiguration="custom" contract="TerytWsTest.ITerytWs1"
        name="custom" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
代码语言:javascript
运行
复制
TerytWs1Client tc = new TerytWs1Client();
tc.ClientCredentials.UserName.UserName = "TestPubliczny";
tc.ClientCredentials.UserName.Password = "1234abcd";
var zalogowany = tc.CzyZalogowany();

我也试过了:

代码语言:javascript
运行
复制
try { 
var proxy = new ChannelFactory<TerytWsTest.ITerytWs1>("custom");
proxy.Credentials.UserName.UserName = "TestPubliczny";
proxy.Credentials.UserName.Password = "1234abcd";
var result = proxy.CreateChannel();
var test = result.CzyZalogowany();
} 
catch (Exception ex) { }
EN

回答 1

Stack Overflow用户

发布于 2021-02-23 15:03:13

首先你要确保你的WCF服务已经启动,你可以通过浏览器检查WCF服务是否已经启动:

然后,您可以通过添加服务引用来调用WCF服务:

点击OK后,会自动生成proxy类,我们可以通过proxy类调用WCF服务:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66327478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档