WCF端点地址不起作用

时间:2011-07-22 05:27:41

标签: wcf iis

有人可以告诉我下面我做错了什么吗?几个小时以来我一直在与这个斗争,并相信我说得对,但我必须遗漏一些东西。基本上对于我所拥有的每项服务我都想要解决。这些服务将托管在IIS中。我一直在测试IIS Express。我的期望是我将访问/AuthService.svc/soap和/AuthService.svc/json中的服务,但这似乎不起作用。下面是我正在使用的配置。

<system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="jsonBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="SecureBinding" allowCookies="true" maxReceivedMessageSize="67108864">
          <readerQuotas maxArrayLength="67108864"/>
          <security mode="Transport"/>
        </binding>
      </basicHttpBinding>
      <webHttpBinding>
        <binding name="SecureBinding" allowCookies="true" maxReceivedMessageSize="67108864">
          <readerQuotas maxArrayLength="67108864"/>
          <security mode="Transport"/>
        </binding>
      </webHttpBinding>
      </bindings>
      <services>
        <service name="AuthService" behaviorConfiguration="DefaultServiceBehavior">
          <endpoint address="soap"
                  binding="basicHttpBinding"
                  bindingConfiguration="SecureBinding" 
                  contract="FormsAuthenticatingServices.Interfaces.IAuthService" />
          <endpoint address="json"
                  binding="webHttpBinding"
                  bindingConfiguration="SecureBinding"
                  behaviorConfiguration="jsonBehavior"
                  contract="FormsAuthenticatingServices.Interfaces.IAuthService" />
        </service>
        <service name="DataService" behaviorConfiguration="DefaultServiceBehavior">
          <endpoint address="soap"
                  binding="basicHttpBinding"
                  bindingConfiguration="SecureBinding"
                  contract="FormsAuthenticatingServices.Interfaces.IDataService" />
          <endpoint address="json"
                  binding="webHttpBinding"
                  bindingConfiguration="SecureBinding"
                  behaviorConfiguration="jsonBehavior"
                  contract="FormsAuthenticatingServices.Interfaces.IDataService" />
        </service>
      </services>
    </system.serviceModel>

2 个答案:

答案 0 :(得分:2)

您应该从/authservice.svc?wsdl获取基于SOAP的元数据,并从URI /authservice.svc/json

开始获取基于REST的操作

通过点击/authservice.svc/soap,您不会在浏览器中看到任何内容,因为SOAP假定XML消息将被POST到服务,而浏览器正在执行GET。要使用SOAP服务,请使用指向WSDL的“添加服务引用”来创建客户端项目并生成代理

答案 1 :(得分:1)

除了Richard的回答,请确保&lt; service&gt;上的name属性。 element是服务类的完全限定名称。