Добрый день!
Есть WCF сервис по передаче файлов с сервера клиенту:
IOAuth.cs
[OperationContract(Name = "FileServerToClient")]
byte[] FileServerToClient(string type);
OAuth.cs
public byte[] FileServerToClient(string type)
{
try
{
if (type == "Client")
{
FileStream fs = new FileStream(@"E:\Обновление ГАС Управление\Update\GAS-ASU.exe", FileMode.Open);
buffer = new byte[fs.Length];
int len = (int)fs.Length;
fs.Read(buffer, 0, len);
fs.Close();
}
else
{
if (type == "Config")
{
FileStream fs = new FileStream(@"E:\Обновление ГАС Управление\Update\GAS-ASU.exe.config", FileMode.Open);
buffer = new byte[fs.Length];
int len = (int)fs.Length;
fs.Read(buffer, 0, len);
fs.Close();
}
}
}
catch (Exception ex)
{
log(ex.ToString(), "Функция Update_file");
}
return buffer;
}
Конфиг сервера (ip адреса изменены)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<services>
<service behaviorConfiguration="mexBehaviors" name="Сервер_авторизации.OAuth">
<endpoint address="OAuth" binding="basicHttpBinding" contract="Сервер_авторизации.IOAuth" />
<endpoint address="OAuth" binding="mexTcpBinding" contract="Сервер_авторизации.IOAuth" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://10.10.10.10:1020/" />
<add baseAddress="net.tcp://10.10.10.10:1021/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviors">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="ServiceWithAuthentication.CustomUserNameValidator, ServiceWithAuthentication" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<security>
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
и клиент (выдержка из клиента):
var client = new svc.OAuthClient("MetadataExchangeTcpBinding_IOAuth");
client.Open();
FileStream fss = new FileStream(Application.StartupPath + @"\GAS-ASU.exe", FileMode.Create, FileAccess.Write);
fss.Write(client.FileServerToClient("Client"), 0, client.FileServerToClient("Client").Length);
fss.Close();
Конфиг клиента
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IOAuth" closeTimeout="00:05:00" openTimeout="00:05:00" maxBufferPoolSize="2147000000" maxBufferSize="2147000000" maxReceivedMessageSize="2147000000" />
</basicHttpBinding>
<netTcpBinding>
<binding name="MetadataExchangeTcpBinding_IOAuth" openTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="2147000000" maxBufferSize="2147000000" maxReceivedMessageSize="2147000000">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="http://10.10.10.10:1020/OAuth" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IOAuth" contract="svc.IOAuth" name="BasicHttpBinding_IOAuth" />
<endpoint address="net.tcp://10.10.10.10:1021/OAuth" binding="netTcpBinding" bindingConfiguration="MetadataExchangeTcpBinding_IOAuth" contract="svc.IOAuth" name="MetadataExchangeTcpBinding_IOAuth" />
</client>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<appSettings>
<add key="departament" value="Lan" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
На Windows 7 работает все на ура, но как только дело касается Windows XP то тут беда...
файл GAS-ASU.exe и GAS-ASU.exe.config создаеться в 0 Кб, в чем может быть причина и как ее исправить?
Не откажусь от другого способа передачи файлов от сервера клиенту.
Заранее всем спасибо.