WCF服务无法在Cassini中加载元数据错误

时间:2013-06-01 17:46:28

标签: c# .net wcf metadata mex

这是我的第一个WCF服务,我遇到了新手的常见问题,即配置文件。

服务项目是使用herehere中的示例创建的,在收到错误[Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.]后,我浏览了Web.config here和{的MSDN方式{3}}

这是我的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中运行,因此我没有浏览器上下文。

0 个答案:

没有答案