我的本地機器中有一個WCF服務,它的作用類似於客戶端應用程序和遠程數據庫之間的「橋樑」。當POST一些數據時WCF錯誤400錯誤的請求
WCF服務與實體框架類一起工作,並且在獲取數據時工作正常,但在發佈任何內容時無法正常工作,並且收到下一條錯誤消息:「(400)Bad Request」。
這是我的客戶端代碼:
//Connect to WCF Service
CHS_Local.ServiceFrontalClient proxy = new CHS_Local.ServiceFrontalClient();
//Get a "Client" class wich ClientID == 1
CHS_Local.Client client = proxy.GetClient(1);
//Change some stuff
client.Name = "change someting";
//Send the modified class to service to update the database
proxy.UpdateClient(client);
這是我<system.serviceModel>
標籤WCF中的配置文件:
<system.serviceModel>
<services>
<service name="CentralizedHostingService.ServiceFrontal">
<endpoint
address=""
binding="wsHttpBinding"
contract="CentralizedHostingService.IServiceFrontal">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/CentralizedHostingService/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
和我的客戶端應用程序app.config
:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IServiceFrontal" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="5000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas
maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint
address="http://localhost:8732/Design_Time_Addresses/CentralizedHostingService/Service1/"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IServiceFrontal"
contract="CHS_Local.IServiceFrontal" name="WSHttpBinding_IServiceFrontal">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
服務接口:
[OperationContract]
Client GetClient(int clientID);
[OperationContract]
void UpdateClient(Client editedClient);
在第一個例子中,雖然問題存在於請願的權重,但我看到使用Fiddler字節發送請求只有115.903字節(〜0.11MB)。 有什麼想法?
正如你所看到的是一個簡單的例子,但沒有工作:(
感謝您幫助!:)
把你的服務interace這裏 – Aliostad 2011-03-08 17:39:37