http 上没有侦听端点 // 可以接受 WCF 中的消息

2024-02-24

我正在尝试开发一个webservice。在我的应用程序中,我需要连接到我的webservice没有任何引用,所以我使用这段代码:

static void Main(string[] args)
{            

    BasicHttpBinding binding = new BasicHttpBinding();
    EndpointAddress address = new EndpointAddress("http://confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc");
    ChannelFactory<IService1> factory = new ChannelFactory<IService1>(binding, address);
    IService1 channel = factory.CreateChannel();

    Console.WriteLine(channel.GetCategoryName(1));
    Console.ReadLine();
}

但在这一行channel.GetCategoryName(1)我收到此错误:

There was no endpoint listening at http://confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

这是我的service webconfig:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
    </serviceHostingEnvironment>
    <services>
      <service name="WcfServiceLibrary1.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc" binding="basicHttpBinding" contract="WcfServiceLibrary1.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>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <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>
  </system.serviceModel>

</configuration>

注意:当我添加引用时它起作用,当我不将其添加到引用时它不起作用。

错误堆栈跟踪:

System.ServiceModel.EndpointNotFoundException was unhandled by user code
  HResult=-2146233087
  Message=There was no endpoint listening at http://confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at WcfServiceLibrary1.IService1.GetCategoryName(Int32 productID)
       at WebApplication1.WebForm1.Page_Load(Object sender, EventArgs e) in c:\Users\ehsan\Documents\Visual Studio 2012\Projects\WcfService1\WebApplication1\WebForm1.aspx.cs:line 20
       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: System.Net.WebException
       HResult=-2146233079
       Message=The remote server returned an error: (404) Not Found.
       Source=System
       StackTrace:
            at System.Net.HttpWebRequest.GetResponse()
            at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       InnerException

你说当你添加参考文献时它起作用了。所以我的猜测是你的端点有问题。

根据您的代码,您期望端点是http://confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc。但你的实际终点是http://confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc/confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc.

在您的 wsdl 中,它将 url 显示为

<wsdl:service name="Service1">
<wsdl:port name="BasicHttpBinding_IService1" binding="tns:BasicHttpBinding_IService1"> 
<soap:address location="http://confdemo.spadsystem.com
/WcfServiceLibrary1.Service1.svc/confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc"/>
</wsdl:port>
</wsdl:service>

我认为您的 web.config 这部分不正确。

<endpoint address="confdemo.spadsystem.com/WcfServiceLibrary1.Service1.svc" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1">

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

http 上没有侦听端点 // 可以接受 WCF 中的消息 的相关文章

  • 如何将 std::string& 转换为 C# 引用字符串

    我正在尝试将 C 函数转换为std string参考C 我的 API 如下所示 void GetStringDemo std string str 理想情况下 我希望在 C 中看到类似的东西 void GetStringDemoWrap r
  • 在模板类中声明模板友元类时出现编译器错误

    我一直在尝试实现我自己的链表类以用于教学目的 我在迭代器声明中指定了 List 类作为友元 但它似乎无法编译 这些是我使用过的 3 个类的接口 Node h define null Node
  • C# 异步等待澄清?

    我读了here http blog stephencleary com 2012 02 async and await html that 等待检查等待的看看它是否有already完全的 如果 可等待已经完成 那么该方法将继续 运行 同步
  • 通过引用传递 [C++]、[Qt]

    我写了这样的东西 class Storage public Storage QString key const int value const void add item QString int private QMap
  • C++11 删除重写方法

    Preface 这是一个关于最佳实践的问题 涉及 C 11 中引入的删除运算符的新含义 当应用于覆盖继承父类的虚拟方法的子类时 背景 根据标准 引用的第一个用例是明确禁止调用某些类型的函数 否则转换将是隐式的 例如最新版本第 8 4 3 节
  • 对类 static constexpr 结构的未定义引用,g++ 与 clang

    这是我的代码 a cp p struct int2 int x y struct Foo static constexpr int bar1 1 static constexpr int2 bar2 1 2 int foo1 return
  • 需要帮助优化算法 - 两百万以下所有素数的总和

    我正在尝试做一个欧拉计划 http projecteuler net问题 我正在寻找 2 000 000 以下所有素数的总和 这就是我所拥有的 int main int argc char argv unsigned long int su
  • WPF 数据绑定到复合类模式?

    我是第一次尝试 WPF 并且正在努力解决如何将控件绑定到使用其他对象的组合构建的类 例如 如果我有一个由两个单独的类组成的类 Comp 为了清楚起见 请注意省略的各种元素 class One int first int second cla
  • 使用 C# 中的 CsvHelper 将不同文化的 csv 解析为十进制

    C 中 CsvHelper 解析小数的问题 我创建了一个从 byte 而不是文件获取 csv 文件的类 并且它工作正常 public static List
  • 两个静态变量同名(两个不同的文件),并在任何其他文件中 extern 其中一个

    在一个文件中将变量声明为 static 并在另一个文件中进行 extern 声明 我认为这会在链接时出现错误 因为 extern 变量不会在任何对象中看到 因为在其他文件中声明的变量带有限定符 static 但不知何故 链接器 瑞萨 没有显
  • x:将 ViewModel 方法绑定到 DataTemplate 内的事件

    我基本上问同样的问题这个人 https stackoverflow com questions 10752448 binding to viewmodels property from a template 但在较新的背景下x Bind V
  • C 编程:带有数组的函数

    我正在尝试编写一个函数 该函数查找行为 4 列为 4 的二维数组中的最大值 其中二维数组填充有用户输入 我知道我的主要错误是函数中的数组 但我不确定它是什么 如果有人能够找到我出错的地方而不是编写新代码 我将不胜感激 除非我刚去南方 我的尝
  • C# 动态/expando 对象的深度/嵌套/递归合并

    我需要在 C 中 合并 2 个动态对象 我在 stackexchange 上找到的所有内容仅涵盖非递归合并 但我正在寻找能够进行递归或深度合并的东西 非常类似于jQuery 的 extend obj1 obj2 http api jquer
  • 为什么使用小于 32 位的整数?

    我总是喜欢使用最小尺寸的变量 这样效果就很好 但是如果我使用短字节整数而不是整数 并且内存是 32 位字可寻址 这真的会给我带来好处吗 编译器是否会做一些事情来增强内存使用 对于局部变量 它可能没有多大意义 但是在具有数千甚至数百万项的结构
  • 复制目录下所有文件

    如何将一个目录中的所有内容复制到另一个目录而不循环遍历每个文件 你不能 两者都不Directory http msdn microsoft com en us library system io directory aspx nor Dir
  • C# 中的 IPC 机制 - 用法和最佳实践

    不久前我在 Win32 代码中使用了 IPC 临界区 事件和信号量 NET环境下场景如何 是否有任何教程解释所有可用选项以及何时使用以及为什么 微软最近在IPC方面的东西是Windows 通信基础 http en wikipedia org
  • C++ 继承的内存布局

    如果我有两个类 一个类继承另一个类 并且子类仅包含函数 那么这两个类的内存布局是否相同 e g class Base int a b c class Derived public Base only functions 我读过编译器无法对数
  • 使用特定参数从 SQL 数据库填充组合框

    我在使用参数从 sql server 获取特定值时遇到问题 任何人都可以解释一下为什么它在 winfom 上工作但在 wpf 上不起作用以及我如何修复它 我的代码 private void UpdateItems COMBOBOX1 Ite
  • 为什么C++代码执行速度比java慢?

    我最近用 Java 编写了一个计算密集型算法 然后将其翻译为 C 令我惊讶的是 C 的执行速度要慢得多 我现在已经编写了一个更短的 Java 测试程序和一个相应的 C 程序 见下文 我的原始代码具有大量数组访问功能 测试代码也是如此 C 的
  • 如何确定 CultureInfo 实例是否支持拉丁字符

    是否可以确定是否CultureInfo http msdn microsoft com en us library system globalization cultureinfo aspx我正在使用的实例是否基于拉丁字符集 我相信你可以使

随机推荐

  • 如何在 WordPress 多站点中显示最近的全局帖子

    我在 ayp no 上运行一个 wordpress 多站点 我正在尝试找出一种方法来呈现所有子站点的徽标和所有博客的最新帖子 我知道有一个 wpmudev 高级插件 但我希望有一些编码我可以自己做 好吧 显然不是我自己 但至少在这里问一下并
  • 在 Swift 中更改 UITabBar selectedItem

    如何以编程方式更改 UITabBar 中的选定项目 Swift 3 及更高版本 从 Swift 3 开始 您还可以使用 tabBarController selectedIndex 0 or any other existing index
  • 优雅地崩溃内核

    后续 CUDA 停止所有其他线程 https stackoverflow com questions 3735786 cuda stop all other threads 我正在寻找一种在发生 不良情况 时退出内核的方法 编程手册说 NV
  • graphviz 中的子图布局

    我有显示两个子图的代码 graph rankdir LR subgraph cluster01 label t 0 a0 label A a1 label B a2 label C a5 label E a0 a1 a1 a2 a2 a0
  • 使用自定义表单替换部分 Outlook 客户端窗口

    我正在为 Outlook 客户端开发 VSTO 应用程序 我正在尝试在 Outlook 客户端窗口的部分中打开我的表单 该部分在下图中以红色突出显示 我认为我不能使用表单区域 因为它们替换了单个项目的视图 所以基本上我想做的是当我单击工具栏
  • 分段读取 CSV 文件的策略?

    我的计算机上有一个中等大小的文件 4GB CSV 但没有足够的 RAM 来读取该文件 64 位 Windows 上为 8GB 在过去 我只是将其加载到集群节点上并将其读入 但我的新集群似乎任意将进程限制为 4GB RAM 尽管每台机器的硬件
  • 提交到 App Store 的应用程序和应用程序更新必须使用 Xcode 5.1.1 或更高版本以及 iOS 7 SDK 构建

    今天使用新的 iTunes 连接网页时出现此错误 我的xCode版本是 我的SDK是 我之前提交的内容是使用旧网页进行的 现在新网页不断抱怨我的新版本出现此错误 有人看到同样的问题吗 好的 这可能是他们网站的问题 现在刚刚尝试使用清理后的版
  • Android-Studio-1.2.RC 关于 Square 的 Okio 库参考的 Proguard 警告

    使用 Android Studio 1 2 RC 我在 gradle 中启用了 proguard minifyEnabled true and added these rules to my proguard rules pro dontw
  • 为什么使用 OleDb 导入 Excel 时会忽略第一个空行

    使用 Net 的 OleDb 我尝试导入一个 Excel 表 其中第一行可以为空 我想保留 DataTable 中的空行 以便稍后能够将单元格映射到 Excel 样式的单元格名称 A1 A2 但无论我做什么 第一行都会被删除 Excel 文
  • 列出 Cucumber 中所有可用的标签

    是否有命令行选项可以列出黄瓜测试套件中的所有标签 例如 我想要这样的东西 cucumber show tags foo feature 那会给我类似的东西 ci development regression wip 对于单个文件 cucum
  • Spring 4 RestController JSON:根据请求“接受”标头,特征不可接受

    我正在使用 spring 4 1 1 RELEASE 并在 pom 中包含了 jackson core asl 1 9 13 和 jackson mapper asl 1 9 13 以使用 RestController 创建一个简单的应用程
  • 为什么单元格渲染器经常扩展 JLabel?

    我注意到这很常见 例如 DefaultListCellRenderer DefaultTableCellRenderer 和 DefaultTreeCellRenderer 都使用它 我在网上看到的许多自定义单元格渲染器也使用它 我想在代码
  • 使用 Php 5 和 MySQL 进行 GPS 半径搜索

    我有一个PlaceID PlaceName Lat Lon作为我的数据库结构 假设我当前的纬度和经度为 lat 37 331862 lon 122 029937 我想找到半径 100 英尺内的地方 可能允许用户选择 您可能有兴趣查看以下演示
  • switch 语句的 Jacoco 覆盖范围

    我正在努力为我正在开发的库获得 100 的代码覆盖率 但我似乎在 switch 语句和覆盖率方面遇到了一些问题 我根本不理解 我目前正在使用 Jacoco 0 7 2 因为每个新版本似乎都与 Robolectrics 发生冲突 我测试了一个
  • 猫鼬预保存挂钩中的异步功能不起作用

    在预保存挂钩中调用异步函数正在返回我undefined密码 我是否从根本上误解了async这里 我已经在我的应用程序的其他区域成功使用它 它似乎工作正常 userSchema pre save function next let user
  • localStorage()、window.localStorage() 或 document.localStorage() 哪个选项更好?

    这个问题说明了一切 我意识到所有的选择do在最新的浏览器中工作 但是语义上最好的选择是什么 为什么 根据W3C标准 正确的是window localStorage因为localStorage属性是 window 对象的一部分 它不是一个函数
  • (任何语言)使用交换查找向量中元素的所有排列

    今天在实验室会议上有人问我这个问题 我们可以想象一个包含元素 1 N 1 长度为 N 的向量 是否存在生成向量中元素的所有排列或顺序的算法 系统 方法 一种建议的方法是交换随机元素 显然 如果存储所有先前生成的排列以供将来参考 那么这将起作
  • 在 Visual Studio 2019 中配置 CMake 版本

    有没有办法配置Visual Studio 2019集成CMake版本 我想使用最新 CMake 版本中的一些功能 但在这种情况下我被迫从命令行构建 如果我从 VS IDE 构建 则使用的 CMake 版本是 Visual Studio 集成
  • Chrome 41 ERR_SSL_VERSION_OR_CIPHER_MISMATCH Tomcat 7

    由于我已将 Chrome 从版本 40 更新到 41 我无法再访问在本地 tomcat 7 实例中运行的 ssl 站点 我有一个自签名证书 Chrome 只打印This webpage is not available和 一起ERR SSL
  • http 上没有侦听端点 // 可以接受 WCF 中的消息

    我正在尝试开发一个webservice 在我的应用程序中 我需要连接到我的webservice没有任何引用 所以我使用这段代码 static void Main string args BasicHttpBinding binding ne