wcf - 元数据包含无法解析的引用

标签 wcf

我在 SO 上查看了一大堆其他帖子,但没有一个解决了我的问题。

我已经在本地机器上的 IIS 中设置了 WCF Web 服务,我可以正常浏览它,但是当我尝试将其添加为服务引用时出现此错误:

Metadata contains a reference that cannot be resolved: 'http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc'.
Metadata contains a reference that cannot be resolved: 'http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc'.
If the service is defined in the current solution, try building the solution and adding the service reference again.

具体来说,我不明白为什么它说它无法解析 http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc 当这是确切的地址我正在浏览。

这是我的配置文件:

<configuration>
  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WebServices.Services.AccessSetupService">
        <endpoint address="" binding="wsHttpBinding" contract="WebServices.Services.IAccessSetupV1">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBinding"></binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

编辑:这是 WSDL:

<wsdl:definitions name="AccessSetupService" targetNamespace="http://tempuri.org/">
  <wsp:Policy wsu:Id="WSHttpBinding_IAccessSetupV1_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <sp:SymmetricBinding>
          <wsp:Policy>
            <sp:ProtectionToken>
              <wsp:Policy>
                <sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                  <wsp:Policy>
                    <sp:RequireDerivedKeys/>
                    <sp:BootstrapPolicy>
                      <wsp:Policy>
                        <sp:SignedParts>
                          <sp:Body/>
                          <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
                          <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
                          <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                          <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                          <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
                          <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
                          <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
                        </sp:SignedParts>
                        <sp:EncryptedParts>
                          <sp:Body/>
                        </sp:EncryptedParts>
                        <sp:SymmetricBinding>
                          <wsp:Policy>
                            <sp:ProtectionToken>
                              <wsp:Policy>
                                <sp:SpnegoContextToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                                  <wsp:Policy>
                                    <sp:RequireDerivedKeys/>
                                  </wsp:Policy>
                                </sp:SpnegoContextToken>
                              </wsp:Policy>
                            </sp:ProtectionToken>
                            <sp:AlgorithmSuite>
                              <wsp:Policy>
                                <sp:Basic256/>
                              </wsp:Policy>
                            </sp:AlgorithmSuite>
                            <sp:Layout>
                              <wsp:Policy>
                                <sp:Strict/>
                              </wsp:Policy>
                            </sp:Layout>
                            <sp:IncludeTimestamp/>
                            <sp:EncryptSignature/>
                            <sp:OnlySignEntireHeadersAndBody/>
                          </wsp:Policy>
                        </sp:SymmetricBinding>
                        <sp:Wss11>
                          <wsp:Policy/>
                        </sp:Wss11>
                        <sp:Trust10>
                          <wsp:Policy>
                            <sp:MustSupportIssuedTokens/>
                            <sp:RequireClientEntropy/>
                            <sp:RequireServerEntropy/>
                          </wsp:Policy>
                        </sp:Trust10>
                      </wsp:Policy>
                    </sp:BootstrapPolicy>
                  </wsp:Policy>
                </sp:SecureConversationToken>
              </wsp:Policy>
            </sp:ProtectionToken>
            <sp:AlgorithmSuite>
              <wsp:Policy>
                <sp:Basic256/>
              </wsp:Policy>
            </sp:AlgorithmSuite>
            <sp:Layout>
              <wsp:Policy>
                <sp:Strict/>
              </wsp:Policy>
            </sp:Layout>
            <sp:IncludeTimestamp/>
            <sp:EncryptSignature/>
            <sp:OnlySignEntireHeadersAndBody/>
          </wsp:Policy>
        </sp:SymmetricBinding>
        <sp:Wss11>
          <wsp:Policy/>
        </sp:Wss11>
        <sp:Trust10>
          <wsp:Policy>
            <sp:MustSupportIssuedTokens/>
            <sp:RequireClientEntropy/>
            <sp:RequireServerEntropy/>
          </wsp:Policy>
        </sp:Trust10>
        <wsaw:UsingAddressing/>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="WSHttpBinding_IAccessSetupV1_Configure_Input_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <sp:SignedParts>
          <sp:Body/>
          <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
        </sp:SignedParts>
        <sp:EncryptedParts>
          <sp:Body/>
        </sp:EncryptedParts>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="WSHttpBinding_IAccessSetupV1_Configure_output_policy">
    <wsp:ExactlyOne>
      <wsp:All>
        <sp:SignedParts>
          <sp:Body/>
          <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing"/>
          <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing"/>
        </sp:SignedParts>
        <sp:EncryptedParts>
          <sp:Body/>
        </sp:EncryptedParts>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types>
    <xsd:schema targetNamespace="http://tempuri.org/Imports">
      <xsd:import schemaLocation="http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="IAccessSetupV1_Configure_InputMessage">
    <wsdl:part name="parameters" element="tns:Configure"/>
  </wsdl:message>
  <wsdl:message name="IAccessSetupV1_Configure_OutputMessage">
    <wsdl:part name="parameters" element="tns:ConfigureResponse"/>
  </wsdl:message>
  <wsdl:portType name="IAccessSetupV1">
    <wsdl:operation name="Configure">
      <wsdl:input wsaw:Action="http://tempuri.org/IAccessSetupV1/Configure" message="tns:IAccessSetupV1_Configure_InputMessage"/>
      <wsdl:output wsaw:Action="http://tempuri.org/IAccessSetupV1/ConfigureResponse" message="tns:IAccessSetupV1_Configure_OutputMessage"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="WSHttpBinding_IAccessSetupV1" type="tns:IAccessSetupV1">
    <wsp:PolicyReference URI="#WSHttpBinding_IAccessSetupV1_policy"/>
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="Configure">
      <soap12:operation soapAction="http://tempuri.org/IAccessSetupV1/Configure" style="document"/>
      <wsdl:input>
        <wsp:PolicyReference URI="#WSHttpBinding_IAccessSetupV1_Configure_Input_policy"/>
        <soap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <wsp:PolicyReference URI="#WSHttpBinding_IAccessSetupV1_Configure_output_policy"/>
        <soap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="AccessSetupService">
    <wsdl:port name="WSHttpBinding_IAccessSetupV1" binding="tns:WSHttpBinding_IAccessSetupV1">
      <soap12:address location="http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc"/>
      <wsa10:EndpointReference>
        <wsa10:Address>http://[Machine Name]/AccessSetupService/WebServices.Services.AccessSetupService.svc</wsa10:Address>
        <Identity>
          <Spn>host/[Machine Name]</Spn>
        </Identity>
      </wsa10:EndpointReference>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

有什么想法吗?我一直在用头撞墙上,我正在做的洞越来越大。

提前谢谢!

最佳答案

我授予 IIS_IUSRS 对 Windows/Temp 文件夹的读写权限,并且它起作用了

关于wcf - 元数据包含无法解析的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6699809/

相关文章:

ruby-on-rails - 如何使用 ruby​​ 使用 wcf 服务?

c# - 如何使用 C# WCF RESTful(即 Web)服务发送 CSV 文件?

asp.net - WCF .SVC 调试 ="true"在发布编译时被忽略?

.net - 在部署环境之间管理复杂的 Web.Config 文件

c# - 如何在 WCF 中使用自定义绑定(bind)并使用用户名客户端凭据保持消息安全模式?

c# - 未将凭据传递给 WCF 服务导致 401

c# - 在 HTTPS 情况下,未使用 HTTP.SYS 正确配置服务器证书

Jquery ajax休息服务调用: Typo Error Access is denied

wcf - WCF 中的 mexTcpBinding - IMetadataExchange 错误

wcf - 如何将裸结果返回给 WCF 客户端