【发布时间】:2015-03-02 11:11:06
【问题描述】:
我有一个由 Sync Framework 生成的 WCF 客户端/服务器架构。 由于某种原因,我必须将客户端 POST 消息的 HTTP 版本从 1.1 更改为 1.0(因为客户端和服务器之间的代理)
敲了敲键盘后,我发现我必须重写 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);
}
}
如果有人找到答案,我将永远感激那个人。
【问题讨论】:
标签: c# wcf http microsoft-sync-framework