0
嗨,我終於創建了一個小型上傳wcf服務。我可以在我的計算機上傳輸小圖像,但我試圖傳輸mp3歌曲以獲得更大的數據。它滿足「400錯誤請求」例外。我不知道發生了什麼。我流的數據,發現資源,很多在網絡上,但沒有似乎工作,這是我所作爲服務的web.config:與WCF傳輸大數據的問題
<?xml version="1.0"?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="67108864"/>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" messageEncoding="Mtom" maxBufferSize="65536" maxReceivedMessageSize="67108864">
<readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
</binding>
<!--<binding name="ExampleBinding" transferMode="Streamed" messageEncoding="Mtom" />-->
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
這是我的客戶的app.config。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMediaServer" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:49689/MediaServer.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMediaServer" contract="mediaServer.IMediaServer"
name="BasicHttpBinding_IMediaServer" />
</client>
</system.serviceModel>
</configuration>
至於我可以看到我應該能夠接收數據的至少64MB,並且我嘗試傳輸數據大約是4Mb的。任何人都可以點我在正確的方向上的錯誤是在我的配置是什麼(至少我懷疑是錯誤在我的配置)
編輯 這些是我的合同:
[ServiceContract]
public interface IMediaServer
{
[OperationContract]
void UploadData(UploadFile data);
}
[MessageContract]
public class UploadFile
{
public UploadFile() { }
[MessageHeader]
public string FileName { get; set; }
[MessageHeader]
public string Type { get; set; }
[MessageHeader]
public string AccountName { get; set; }
[MessageBodyMember]
public Stream data { get; set; }
}
我做了修改,仍然沒有運氣(原來的帖子改了),現在我的例外是: 消息:遠程服務器返回一個錯誤:(400)錯誤的請求。 堆棧跟蹤: 在System.Net.HttpWebRequest.GetResponse() 在System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(時間跨度超時) – 2010-09-08 08:43:48
它是否以小文件的工作? – 2010-09-08 08:47:08
不......不再...但如果我將客戶端改回緩衝區,它可以正常工作......我錯過了什麼,在我看來,它只能傳輸圖像,它可以放入緩衝區 – 2010-09-08 09:06:45