如何解决WCF-未创建服务引用
| 我的WCF服务正常运行,然后突然停止工作。我不认为我对配置进行了任何更改。 WCF服务由Windows服务托管。 奇怪的是,当我添加服务引用时,它将标识合同和公开的所有方法。但是,如果我使用浏览器,则会收到404错误,并且编译器未创建服务。我删除并尝试重新添加引用,但没有运气 另外,我已部署的应用程序仍然能够访问wcf服务。 问题1: 在WCF Windows服务中,我应该能够在浏览器(http:// localhost:8080 / MaestroService / mex)中看到wsdl。在IE中,我收到了400错误请求。我假设这是问题的根源。 问题2: 还有其他吗? App.config<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name=\"NewBinding0\" />
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name=\"metadataAndDebug\">
<serviceMetadata httpGetEnabled=\"true\" />
<serviceDebug httpHelpPageEnabled=\"true\" includeExceptionDetailInFaults=\"true\" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration=\"metadataAndDebug\" name=\"MaestroServiceLibrary.MaestroService\">
<endpoint address=\"basic\" binding=\"basicHttpBinding\" bindingConfiguration=\"NewBinding0\"
name=\"basicHttp\" contract=\"MaestroServiceLibrary.IMaestroService\" />
<endpoint address=\"mex\" binding=\"mexHttpBinding\" bindingConfiguration=\"\"
contract=\"IMetadataExchange\" />
<endpoint address=\"net.tcp://localhost:8888/MaestroService\" binding=\"netTcpBinding\"
bindingConfiguration=\"\" name=\"netTcpBinding\" contract=\"MaestroServiceLibrary.IMaestroService\" />
<endpoint address=\"net.pipe://localhost/MaestroService\" binding=\"netNamedPipeBinding\"
bindingConfiguration=\"\" name=\"netNamedPipeBinding\" contract=\"MaestroServiceLibrary.IMaestroService\" />
<host>
<baseAddresses>
<add baseAddress=\"http://localhost:8080/MaestroService\" />
</baseAddresses>
</host>
</service>
</services>
错误编译:
Custom tool error: Failed to generate code for the service reference \'MaestroService\'. Please check other error and warning messages for details.
Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
wsdl:portType的XPath:// wsdl:definitions [@ targetNamespace = \'http://tempuri.org/ \'] / wsdl:portType [@name = \'IMaestroService \']
错误的XPath来源:// wsdl:definitions [@ targetNamespace = \'http://tempuri.org/ \'] / wsdl:binding [@name = \'basicHttp \']
更新资料
我打开了跟踪,然后看到了:
由于EndpointDispatcher上的AddressFilter不匹配,因此无法在接收方处理带有To \'http:// localhost:8080 / MaestroService / mex / mex \'的消息。检查发送者和接收者的EndpointAddresses是否一致。如果我弄清楚了,我将更新这个问题。
更新V2
我去了同一个解决方案中的另一个项目。我能够毫无问题地添加服务。我注意到我在控制台应用程序中使用3.5,而在wpf浏览器应用程序中使用4.0。当我回来报告此问题时,即使在url中放置了http:// localhost:8080 / MaestroService / mex,我在上次更新中也注意到它具有/ mex / mex。我只是尝试http:// localhost:8080 / MaestroService而已!!!
最后,我确实在这里使用了Migual Castro技术,在其中创建了问题和代理。看看它是如何工作以及VS在做什么的,这很好。但是,有一天半的时间会很好。
谢谢大家的建议。
解决方法
您正在作为Windows服务运行。
Windows服务在用户帐户的安全上下文中运行。
如果用户帐户的密码更改或到期,则该服务将无法运行。
您应该检查的第一件事是:服务正在运行。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。