none
客户端调用 wcf ,返回error code=415 "unsupported media type" RRS feed

  • 问题

  • 如题, 网上也搜索了好久,没有解决,附上我的web.config:

    <?xml version="1.0"?>
    <configuration>

      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <!--
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>
        -->
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" >
          <serviceActivations>
            <add relativeAddress="User.svc" service="mdmWcfService.User"/>
          </serviceActivations>
        </serviceHostingEnvironment>
        <services>
            <!-- This section is optional with the default configuration model introduced in .NET Framework 4 -->
            <service name="mdmWcfService.User" behaviorConfiguration="ServiceBehavior">
                <host>
                  <baseAddresses>
                    <add baseAddress="http://localhost:8081/mdmwcf/mdmWcfService/User.svc"/>
                  </baseAddresses>
                </host>
                <endpoint address=""
                          binding="wsHttpBinding"
                          contract="mdmWcfService.IUser"
                          />
                <endpoint address="mex"
                          binding="mexHttpBinding"
                          contract="IMetadataExchange"
                          />
            </service>
        </services>
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>

    </configuration>

    User.svc:

    <%@ ServiceHost Language="C#" Debug="false" Service="mdmWcfService.User"  %>

    望高人指点,本人新手,刚接触wcf,用的是vs2012,.net4.5。

    2013年9月10日 8:44

全部回复