2

I'm having some difficulty getting my WCF service configured. My requirement is that it exposes a basicHttpBinding endpoint as well as a netTcpBinding endpoint. Some of my clients are .NET 2.0, and need to be able to generate a proxy via WSDL.exe.

It seems to work for the most part - but when I attempt to get the WSDL, it's not cooperating. In a browser, it gives me back some SOAP XML tags, but definitely not a full WSDL. WSDL.exe gives me a series of errors:

Error: There was an error processing 'http://1.2.3.4:9877/MyService/basicHttp?wsdl'.

  • The document was understood, but it could not be processed.
  • The WSDL document contains links that could not be resolved.
  • There was an error downloading 'http://localhost:9877/MyService/basicHttp?wsdl=wsdl0'.
  • The underlying connection was closed: Unable to connect to the remote server.

Here's my host configuration. Does anything jump out as wrong here?

<system.serviceModel>
  <services>
    <service behaviorConfiguration="MyServiceBehavior" name="MyRunner">
      <endpoint address="netTcp" binding="netTcpBinding" bindingConfiguration="" contract="IMyRunner">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="basicHttp" binding="basicHttpBinding" bindingConfiguration="" contract="IMyRunner">
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
      <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:9876/MyService/netTcp" />
          <add baseAddress="http://localhost:9877/MyService/basicHttp" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="MyServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
4

2 回答 2

1

如果您有两个 MEX 端点,每个端点都需要一个单独的地址 - 调用一个“mex”,然后调用另一个“mex2”或其他东西:

<service behaviorConfiguration="MyServiceBehavior" name="MyRunner">
      <endpoint address="netTcp" binding="netTcpBinding" bindingConfiguration="" contract="IMyRunner">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="basicHttp" binding="basicHttpBinding" bindingConfiguration="" contract="IMyRunner">
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
      <endpoint address="mex2" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:9876/MyService/netTcp" />
          <add baseAddress="http://localhost:9877/MyService/basicHttp" />
        </baseAddresses>
      </host>
    </service>

(好吧,根据 OP 的评论,他不在 IIS 中托管,所以这不相关)

另外:您是否在 IIS 中托管?在这种情况下,您的基址(至少是 HTTP 基址)毫无意义——SVC 文件的服务器、虚拟目录和位置将决定您的服务地址:

http://YourServer/YourVirtualDirectory/SubDirectory/YourService.svc/basicHttp

对于您的“正常”服务端点,或

http://YourServer/YourVirtualDirectory/SubDirectory/YourService.svc/mex

用于基于 HTTP 的 MEX 端点。

于 2011-01-25T06:56:30.163 回答
0

谢谢提醒伙计。事实证明,问题在于指向“localhost”的 baseAddress 值。在生成的 WSDL 中,它仍然显示“localhost”,因此 WSDL.exe 显然是在尝试访问 localhost(我的开发机器)而不是服务器。我将“localhost”更改为托管服务的服务器的实际 IP,并且 WSDL.exe 成功运行,即使在 .NET 1.1 中也是如此。我仍然可以通过使用 svcutil.exe 获得 4.0 版本。

于 2011-01-25T15:59:42.413 回答