0

I have a simple Webserivce (WCF) hosted in a Windows Service(Selfhost). The declaration of the service looks like this :

<service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
        <endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8008/MyAppServiceutv/Integration"/>
          </baseAddresses>
        </host>
      </service>

I can brows the WSDL with this URL :

http://localhost:8008/MyAppServiceutv/Integration?wsdl

When adding the service reference in Visual Studio 2012 I get this exception :

Exception

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:8008/MyAppServiceutv/Integration?xsd=xsd0'.
  • Unable to connect to the remote server

Metadata contains a reference that cannot be resolved: 'http://MyComputer:8008/MyAppServiceutv/Integration?wsdl'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://MyComputer:8008/MyAppServiceutv/Integration?wsdl. The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again.

Moving to Dev Environment

When moving the service to a dev computer everything works just great? Why whould I get the above problems in just one environment? Could this be due to strong security restrictions?

4

1 に答える 1

0

VS2012 インスタンスがサービス ホスト マシンから離れているようです。このように設定を変更してみてください...

  <service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
    <endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://{my fully qualified domain name}:8008/MyAppServiceutv/Integration"/>
      </baseAddresses>
    </host>
  </service>

わかった。今、私は問題を確認しました...説明。.net 4.0 以下 WCF は複数ファイルの WSDL ファイルを生成します。ベース WSDL ファイルは、さまざまなファイルにリンクしています。WDSL ファイル内のリンクは、相対 URI ではなく絶対 URI を使用して他のファイルにリンクします。そのため、Visual Studio が他の WDSL ファイルを見つけようとすると、"localhost" で見つけられません。

.net 4.5 WCF では、問題を解決する SINGLE FILE WSDL を生成できます。しかし、私の意見では、WCF 4.0 は WSDL プロキシの生成を処理するときに壊れています。

于 2013-05-15T15:50:33.747 に答える