1

これは私の最初の WCF サービスであり、初心者にとって一般的な問題と思われるもの、つまり構成ファイルがあります。

サービス プロジェクトはhereおよびhereの例を使用して作成され、エラーを受け取った後[Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.]、Web.config hereおよびhereの MSDN の方法を調べました。

これが私のWeb.configです:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
        <services>
            <service name="Parkalot.WcfClient.Services.UserService">
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:7349/ServiceMetadata" />
                    </baseAddresses>
                </host>
                <endpoint address="/UserService" binding="wsHttpBinding" contract="Parkalot.WcfClient.Services.IUserServiceContract" />
                <!-- Adds a WS-MetadataExchange endpoint at "http://localhost:7349/ServiceMetadata/mex" -->
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="metadataSupport">
                    <!-- Enables the IMetadataExchange endpoint in services that -->
                    <!-- use "metadataSupport" in their behaviorConfiguration attribute. -->
                    <!-- In addition, the httpGetEnabled and httpGetUrl attributes publish -->
                    <!-- Service metadata for retrieval by HTTP/GET at the address -->
                    <!-- "http://localhost:8080/ServiceMetadata?wsdl" -->
                    <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:7349/ServiceMetadata?wsdl" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

エラーの詳細は次のとおりです。

    Error: Cannot obtain Metadata from http://localhost:7349/Services/UserService.svc
If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.
For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error    URI: http://localhost:7349/Services/UserService.svc
Metadata contains a reference that cannot be resolved:
'http://localhost:7349/Services/UserService.svc'.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
HTTP GET Error    URI: http://localhost:7349/Services/UserService.svc
There was an error downloading 'http://localhost:7349/Services/UserService.svc'.

おそらくブラウザでレンダリングすることを意図したエラーから大量の行を削除しました。Visual Studio 内から実行しているため、ブラウザー コンテキストがありません。

4

0 に答える 0