我是WCF的新手,请耐心等待。
我有StudentData.svc.vb,它实现了来自同一个IStudentData.vb的2个接口
2个接口是IStudentData和IHeartbeat 心跳是一种单向操作合同_
我使用IIS 7.5来托管此服务 web.config是
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<bindings />
<client />
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="basicHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</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>
</
创建服务引用后我的app.config是
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IStudentData" maxReceivedMessageSize="2147483647" />
<binding name="BasicHttpBinding_IHeartbeat" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.ortho-sync.com:8080/StudentData.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStudentData"
contract="oStudentData.IStudentData" name="BasicHttpBinding_IStudentData" />
<endpoint address="http://www.ortho-sync.com:8080/StudentData.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHeartbeat"
contract="oStudentData.IHeartbeat" name="BasicHttpBinding_IHeartbeat" />
</client>
</system.serviceModel>
</configuration>
IStudentData有一个类,其中包含一个字节数组的数据库,用于传输图像。 如果我使用一个小文件,它会传输,一切正常 如果我使用1兆图像我得到(413)请求实体太大
我玩过绑定和终点直到我脸色发青, 有人请帮忙。
答案 0 :(得分:1)
您的服务正在获取绑定的默认值,因为您尚未指定自己的默认值basicHttpBinding
或已创建引用您自己的basicHttpBinding
的端点(在服务中)。
您可以通过省略name
属性来使绑定配置成为该绑定的默认配置,如下所示:
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" />
或者,您可以显式创建端点,并使用bindingConfiguration
属性为该端点设置绑定配置:
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IStudentData"
contract="oStudentData.IStudentData"
name="BasicHttpBinding_IStudentData" />
第二个示例假设使用name
BasicHttpBinding_IStudentData
定义了绑定配置。
您可以在服务配置文件中使用其中任何一种。