我有一個由Sync Framework生成的WCF客戶端/服務器體系結構。 由於某些原因,我必須將客戶端的POST消息的HTTP版本從1.1更改爲1.0(因爲客戶端和服務器之間的代理服務器)[WCF] [SyncFramework]如何重寫GetWebRequest?
在鍵盤上敲了敲頭之後,我發現必須重寫GetWebRequest改變什麼,我想關於HTTP協議:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
看來,我必須這樣做,覆蓋在生成Reference.cs文件,但我不能。我似乎錯過了足夠的課程,我可以做到這一點。互聯網上的一些人有這樣的問題,但從來沒有這樣的架構和那種Reference.cs文件。
這裏的Reference.cs代碼:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName = "VinciWCFRef.ISyncVinciSyncContract")]
public interface ISyncVinciSyncContract
{
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ISyncVinciSyncContract/ApplyChanges", ReplyAction = "http://tempuri.org/ISyncVinciSyncContract/ApplyChangesResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession);
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ISyncVinciSyncContract/GetChanges", ReplyAction = "http://tempuri.org/ISyncVinciSyncContract/GetChangesResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession);
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ISyncVinciSyncContract/GetSchema", ReplyAction = "http://tempuri.org/ISyncVinciSyncContract/GetSchemaResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
SyncSchema GetSchema(string[] tableNames, SyncSession syncSession);
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ISyncVinciSyncContract/GetServerInfo", ReplyAction = "http://tempuri.org/ISyncVinciSyncContract/GetServerInfoResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
SyncServerInfo GetServerInfo(SyncSession syncSession);
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ISyncVinciSyncContract/GetServerChanges", ReplyAction = "http://tempuri.org/ISyncVinciSyncContract/GetServerChangesResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
string[] GetServerChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession);
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ISyncVinciSyncContract/Genere_ID_Synchro", ReplyAction = "http://tempuri.org/ISyncVinciSyncContract/Genere_ID_SynchroResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
string[] Genere_ID_Synchro(SyncGroupMetadata groupMetadata, SyncSession syncSession);
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/ISyncVinciSyncContract/TestConnect", ReplyAction = "http://tempuri.org/ISyncVinciSyncContract/TestConnectResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults = true)]
string[] TestConnect(SyncGroupMetadata groupMetadata, SyncSession syncSession);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface ISyncVinciSyncContractChannel : Vinci.VinciWCFRef.ISyncVinciSyncContract, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class SyncVinciSyncContractClient : System.ServiceModel.ClientBase<Vinci.VinciWCFRef.ISyncVinciSyncContract>, Vinci.VinciWCFRef.ISyncVinciSyncContract
{
public SyncVinciSyncContractClient()
{
}
public SyncVinciSyncContractClient(string endpointConfigurationName) :
base(endpointConfigurationName)
{
}
public SyncVinciSyncContractClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}
public SyncVinciSyncContractClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
}
public SyncVinciSyncContractClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public SyncContext ApplyChanges(SyncGroupMetadata groupMetadata, System.Data.DataSet dataSet, SyncSession syncSession)
{
return base.Channel.ApplyChanges(groupMetadata, dataSet, syncSession);
}
public SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
{
return base.Channel.GetChanges(groupMetadata, syncSession);
}
public SyncSchema GetSchema(string[] tableNames, SyncSession syncSession)
{
return base.Channel.GetSchema(tableNames, syncSession);
}
public SyncServerInfo GetServerInfo(SyncSession syncSession)
{
return base.Channel.GetServerInfo(syncSession);
}
public string[] GetServerChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession)
{
return base.Channel.GetServerChanges(groupMetadata, syncSession);
}
public string[] Genere_ID_Synchro(SyncGroupMetadata groupMetadata, SyncSession syncSession)
{
return base.Channel.Genere_ID_Synchro(groupMetadata, syncSession);
}
public string[] TestConnect(SyncGroupMetadata groupMetadata, SyncSession syncSession)
{
return base.Channel.TestConnect(groupMetadata, syncSession);
}
}
如果有人認爲作爲答案,那個人就會有我的感恩永恆。
這最後一個是通過更改隱藏在文件service.wsdl/xsd等中的url'localhost'來解決的......不要問爲什麼url是這樣的,而不是像.config中指定的那個。 。 – thi 2016-03-15 09:04:06