2013-11-12 3 views
0

Я разрабатываю службу wcf, чтобы загрузить файлы xml в базу данных хранилища, по этой причине я ziping файл, сохраняя его в memystream и передавая его службе с помощью PushData (Stream как MemoryStream) К несчастью, я не могу заставить его работать. Кажется, у меня какая-то конфигурация отсутствует или неверна. я разместить службу на МОМ 8.0 как самодостаточна в storageservice.svc Ошибкой Msg является: 400 плохого запросомwcf service bad request 400 streaming

здесь мои файлы конфигурация

стороны клиента приложения конфигурация

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
</startup> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IStorageService"  maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" receiveTimeout="00:10:00"> 
      <security mode="None"/> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://10.5.1.6:8001/StorageService.svc" 
      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStorageService" 
      name="BasicHttpBinding" contract="StorageService.IStorageService" /> 
    </client> 
</system.serviceModel> 
</configuration> 

сервера боковая сетевая конфигурация

<?xml version="1.0" encoding="utf-8"?> 
    <configuration> 
    <system.web> 
    <compilation debug="true" /> 
    <httpRuntime maxRequestLength="2147483647"/> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="Namespace.StorageService"> 
     <endpoint address="" binding="basicHttpBinding" contract="Namespace.IStorageService"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://10.5.1.6:8001/" /> 
      <add baseAddress="net.tcp://10.5.1.6:10001/" /> 
      </baseAddresses> 
     </host> 
    </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior>  
     <dataContractSerializer maxItemsInObjectGraph="2147483646"/> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="basicHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" receiveTimeout="00:10:00" > 
      <security mode="None"/> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
<protocolMapping> 
     <add binding="basicHttpBinding" scheme="http"/> 
    </protocolMapping> 
    </system.serviceModel> 
</configuration> 

Мне очень нужна помощь, пробовал 3 дня, чтобы понять это ... и все буферизуемые didnt помочь что-нибудь

Solutions Пробовал:

  1. Добавить readerquotas элемент в связывании
  2. Использование MTOM messageEncoding
  3. Включить трассировку (несчастливо ничего не делали)

EDIT: Клиент Метод

Using client As New StorageService.StorageServiceClient 
      client.Open() 
      Dim helper As CirrostratusHelper = New CirrostratusHelper 
      Dim data As CirrostratusStorage = helper.GenerateData() 
      Dim gdata = data.GenerateData 
      For Each item In gdata 
       Try 
        Dim memorystream As New MemoryStream 
        Dim databasedaata As ZipArchive = item.Value.DatabaseData 
        databasedaata.Save(memorystream) 
        memorystream.Seek(0, SeekOrigin.Begin) 
        ' this method produces the bad exception ' 
        client.PushData(memorystream) 
       Catch ex As Exception     
        Dim test = ex.Message & ex.StackTrace 
       End Try 
      Next 
      client.Close() 
     End Using 

Servive Метод:

Public Function PushData(DataStream As Stream) As Boolean Implements IStorageService.PushData 
     Const buffersize As Integer = 2048 
      Dim buffer(buffersize) As Byte 
      Dim bytesread As Integer = bytesread = DataStream.Read(buffer, 0, buffersize) 
      Dim DataMemoryStream As New MemoryStream 
      While bytesread > 0 
       bytesread = DataStream.Read(buffer, 0, buffersize) 
       DataMemoryStream.Write(buffer, 0, buffersize) 
      End While 
      DataMemoryStream.Seek(0, SeekOrigin.Begin) 
      Dim zip As ZipArchive = ZipArchive.Read(DataMemoryStream) 
       '...' 
    end function 
+0

Дополнительная информация: файл я хотел отправить ~ 20 МБ – daiNc

+0

Я не вижу проблемы с конфигурацией. Какая функция выглядит так, что потоковая передача xml? – Brian

+0

Другой вопрос ... если вы загружаете с клиента на сервер хранилища, почему вы используете потоковое вещание вместо буферизации? Код, связанный с потоковой передачей, немного сложнее, чем для буферизации. – Brian

ответ

0

Я нашел этот вопрос, речь шла о наименовании для переплета и я забыл сделать конечную точку использовать bindingconfiguration

<bindings> 
    <basicHttpBinding> 
    <binding name="basicHttpBinding_Storage" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed" receiveTimeout="00:10:00" > 
     <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxStringContentLength="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647"/> 
     <security mode="None"/> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_Storage" contract="DynaMed.IStorageService"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
Смежные вопросы