IIS上的WCF服务 - WSDL为空

时间:2015-05-05 11:01:00

标签: web-services wcf iis soap wsdl

我创建了一个WCF服务并将其托管在我的IIS服务器上。然后,我需要编辑schemaLocation。我跟着this post

当我将“?wsdl”添加到网址时,我得到一个空白页面。如果我尝试使用来自SOAPui的WSDL来测试它,我得到这个“错误加载[http://xx.xxx.xx.xx:8095/CardServiceLib.CardService.svc/service?wsdl]:org.apache.xmlbeans.XmlException:org.apache.xmlbeans.XmlException:error:意外结束nul之后的文件

如果我删除了HTTPGetUrl,那么WSDL是正确的,但schemaLocation不是我想要的。使用链接帖子制作的mod,schemaLocation是完美的,但WSDL是空的......为什么?

这可行,但不是我想要的(生成WSDL但链接错误):

<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />

而这不是(不生成WSDL - &gt; 空白页面!!! ):

<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" httpGetUrl="http://xx.xx.xx.xx.:8095/MyService.svc/endpoint"/>

这是我在IIS服务器7上的web.config

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="connectionString" connectionString="server=xxxxx;database=xxxxx;uid=xxxxx;pwd=xxxxx;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="userName" value="admin" />
    <add key="password" value="xxxxx" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
    <add key="SecurityKey" value="xxxxxxxxxx" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
      </providers>
    </membership>
    <!--<roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
      </providers>
    </roleManager>-->
  </system.web>
  <system.serviceModel>
    <standardEndpoints>
        <webHttpEndpoint>
        <!-- the "" standard endpoint is used for auto creating a web endpoint. -->
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
      </webHttpEndpoint>
    </standardEndpoints>
    <bindings>
      <basicHttpBinding>
        <binding name="SecurityByTransport" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Basic" />
            <!--<message clientCredentialType="UserName"/>-->
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="CardServiceLib.CardService" behaviorConfiguration="customBehavior">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SecurityByTransport" name="base" contract="CardServiceLib.ICardService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
        <!--<endpoint address="web" behaviorConfiguration="webHttp" binding="webHttpBinding"
          bindingConfiguration="" name="web" contract="calc.ICalcService">
          <identity>
            <dns value="localhost" />httpGetUrl="http://77.108.40.77:8095/CardServiceLib.CardService.svc/service"
          </identity>
        </endpoint>-->
        <host>
          <baseAddresses>
            <add baseAddress="https://xx.xx.xx.xx:8095/MyService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webHttp">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
        <behavior name="customBehavior">
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" httpGetUrl="http://xx.xx.xx.xx:8095/MyService.Service.svc/service"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="xx,xx" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <!--<protocolMapping>
      <add binding="webHttpBinding" scheme="http"  />
    </protocolMapping>-->
  </system.serviceModel>
      <system.webServer>
        <directoryBrowse enabled="false" />
    </system.webServer>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />  </startup></configuration>

解决 !!我添加了这个

address="http://192.168.1.2/Demo.Service/MultiEndPointsService.svc/basic"

在我的端点代码中,就像用this link编写的那样。

1 个答案:

答案 0 :(得分:0)

我怀疑该问题与访问WSDL所需的身份验证有关。

尝试直接访问元数据网址时,网站会显示以下信息:
“需要验证”
“服务器http://...:8095需要用户名和密码。”

您需要提供正确的凭据或放宽对WSDL的权限。