简体   繁体   English

WCF-未创建服务参考

[英]WCF - Service Reference not be created

My WCF service was working correctly and then all of sudden it stop working. 我的WCF服务正常运行,然后突然停止工作。 I don't think I changed anything with the configuration. 我不认为我对配置进行了任何更改。

The WCF service is hosted by a windows service. WCF服务由Windows服务托管。

What is weird is when I add the service reference, it will identify the contract and all the methods exposed. 奇怪的是,当我添加服务引用时,它将标识合同和公开的所有方法。 But if I go to a browser I get a 404 error and the compiler is not creating the service. 但是,如果我使用浏览器,则会收到404错误,并且编译器未创建服务。 I have deleted and tried to re-add the reference with no luck 我已经删除并尝试重新添加引用,但是没有运气

Also, my deployed application is still able to access the wcf service. 另外,我已部署的应用程序仍然能够访问wcf服务。

Question 1: In a WCF windows service, should I be able to see the wsdl inside a browser (http://localhost:8080/MaestroService/mex). 问题1:在WCF Windows服务中,我是否应该能够在浏览器(http:// localhost:8080 / MaestroService / mex)中看到wsdl。 In IE, I am getting 400 Bad Request. 在IE中,我收到了400错误请求。 I am assuming that this is the root of the problem. 我假设这是问题的根源。

Question 2: Is there something else? 问题2:还有其他东西吗?

App.config 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>

Errors Compiling: 错误编译:

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.

XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IMaestroService'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='basicHttp'] wsdl:portType的XPath://wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='IMaestroService']错误原因的XPath:// wsdl:definitions [@ targetNamespace ='http://tempuri.org/'] / wsdl:binding [@ name ='basicHttp']

Update 更新资料

I turned on the tracing and I saw this: The message with To 'http://localhost:8080/MaestroService/mex/mex' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. 我打开了跟踪,然后看到了:由于EndpointDispatcher上的AddressFilter不匹配,因此无法在接收方处理带有To'http:// localhost:8080 / MaestroService / mex / mex'的消息。 Check that the sender and receiver's EndpointAddresses agree. 检查发送方和接收方的EndpointAddresses是否一致。 I will update this question if I figure it out. 如果我弄清楚了,我将更新这个问题。

Update V2 更新V2

I went to another project inside the same solution. 我去了同一个解决方案中的另一个项目。 I was able to add the service there with no problems. 我能够毫无问题地添加服务。 I notice I was using 3.5 in the console app vs 4.0 in the wpf browser app. 我注意到我在控制台应用程序中使用3.5,而在wpf浏览器应用程序中使用4.0。 When I came back to report this, I noticed in my last update that it had /mex/mex even though I put http://localhost:8080/MaestroService/mex in the url . 当我回来报告此问题时,即使在URL中放置了http:// localhost:8080 / MaestroService / mex ,我在上次更新中也注意到它具有/ mex / mex。 I tried just http://localhost:8080/MaestroService and it work!!! 我只是尝试http:// localhost:8080 / MaestroService而已!!!

In the end, I did end up using Migual Castro technique here , where you create the conracts and the proxy. 最后,我确实在这里使用了Migual Castro技术,在其中创建了问题和代理。 Which was good to see how it really works and what VS is doing. 很好看它是如何工作的以及VS在做什么。 But it would be good to have that day and a half back. 但是那一天半回来会很好。

thanks for the suggestions everyone. 谢谢大家的建议。

You are running as a windows service. 您正在作为Windows服务运行。

A windows service runs in the security context of a user account. Windows服务在用户帐户的安全上下文中运行。

If the password of the user account changes or expires, the service does not run. 如果用户帐户的密码更改或到期,则该服务将无法运行。

The first thing that you should check is: Is the service running. 您应该检查的第一件事是:服务正在运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM