Laden...

WCF größeres Arary senden

Erstellt von itstata vor 14 Jahren Letzter Beitrag vor 14 Jahren 4.177 Views
I
itstata Themenstarter:in
302 Beiträge seit 2008
vor 14 Jahren
WCF größeres Arary senden

Hallo zusammen,
ich scheiter mal wieder an einem scheinbar simplen Problem.

ich möchte ein Integer-Array mit über 1000 Einträgen an den Webservice senden.
Dazu verwendet ich folgende WS-Methode.


 public interface IService1
    {

        [OperationContract]
        void SendData(int[] largeArray);
        // AUFGABE: Hier Dienstvorgänge hinzufügen
    }

Und einen Client der einfach ein Array sendet:


class Program
    {
        static void Main(string[] args)
        {
            using (ServiceReference1.Service1Client client = new WCFTestServiceReference1.Service1Client())
            {
                List<int> liste = new List<int>();
                for (int i = 0; i < 3000; i++)
                {
                    liste.Add(i);
                }

                client.SendData(liste.ToArray()) ;
            }
        }
    }

Nun schlägt dieser Aufruf leider fehl da das Array scheinbar zu groß ist (mit einem Array der größe 1000 funktioniert es):

Der Remoteserver hat eine unerwartete Antwort zurückgegeben: (400) Bad Request.

meine config sieht so aus:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <httpRuntime maxRequestLength="2097151" />
  </system.web>
  <system.serviceModel>

    <bindings>

      <wsHttpBinding>
        <binding  name="WSHttpBinding_IService1" closeTimeout="00:10:00" openTimeout="00:10:00"
                  receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false"
                  hostNameComparisonMode="StrongWildcard"  maxBufferPoolSize="524288" maxReceivedMessageSize="6000000">
          <readerQuotas maxDepth="32" maxStringContentLength="524288" maxArrayLength="6000000" maxBytesPerRead="1048576" maxNameTableCharCount="262144" />

          <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" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:2916/Service1.svc" binding="wsHttpBinding"
          bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
          name="WSHttpBinding_IService1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

Ich kann das nicht wirklich verstehen da 3000 Einträge nach meiner Meinung nicht viel ist. Vielleicht hab ich auch einfach irgendein Attribut beim Binding vergessen. Hatte von euch schon mal dieses Problem?

J
1.114 Beiträge seit 2007
vor 14 Jahren

Versuche mal, im Config File einige Binding Parameter zu erhöhen:

maxBufferSize="200000000" maxReceivedMessageSize="200000000" maxBufferPoolSize="200000000"

maxBufferPoolSize hast du ja schon drin stehen, versuch mal die anderen zu ergänzen.

I
itstata Themenstarter:in
302 Beiträge seit 2008
vor 14 Jahren

hallo,
das hat leider auch nicht geholfen...

maxBufferPoolSize geht auch schinbar nur in der basichHttp-Bindung

J
1.114 Beiträge seit 2007
vor 14 Jahren

maxBufferPoolSize geht auch schinbar nur in der basichHttp-Bindung

Ach so? Und jetzt, wo du's sagst, hatte ich das Beispiel auch aus einem basicHttpBinding genommen. Ich hatte da nämlich dasselbe Problem und konnte es so lösen. Bei wsHttp kann ich dir so direkt auch nicht weiterhelfen.

I
itstata Themenstarter:in
302 Beiträge seit 2008
vor 14 Jahren

verdammt... da bekomme ich den gleichen fehler 😃 "bad request (400)"


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="HttpBinding_IService1"
                 transferMode="StreamedRequest" maxBufferSize="200000000" maxReceivedMessageSize="200000000" maxBufferPoolSize="200000000" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:2916/Service1.svc" binding="basicHttpBinding"
          bindingConfiguration="HttpBinding_IService1" contract="ServiceReference1.IService1"
          name="HttpBinding_IService1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
</configuration>

Das ist schon etwas traurig wenn man nichtmal ein paar Zahlen von a nach b schaufeln kann...arg

I
itstata Themenstarter:in
302 Beiträge seit 2008
vor 14 Jahren

also an der maximalgröße der soap-nachricht sollte es nicht liegen.

Technically speaking, the maximum, MAXIMUM size of a SOAP message that we can process in WCF is 9,223,372,036,854,775,807 bytes.

S
8.746 Beiträge seit 2005
vor 14 Jahren

Könnte es sein dass da nen Proxy dazwischenhängt? Bad Request ist normalerweise keine übliche WCF-Fehlermeldung.

Ansonsten würde ich das erstmal mit einem normalen basicHttpBinding probieren.

I
itstata Themenstarter:in
302 Beiträge seit 2008
vor 14 Jahren

hallo svenson...
kann es auch sein, dass ich einen WSDualHttpBinding (also Duplex) verwenden muss?
http://msdn.microsoft.com/en-us/library/ms731092.aspx

auf diesem link steht folgendes:

WSHttpBinding<wsHttpBinding>
A secure and interoperable binding that is suitable for non-duplex service contracts.

WSDualHttpBinding
<wsDualHttpBinding>
A secure and interoperable binding that is suitable for duplex service contracts or communication through SOAP intermediaries.

I
itstata Themenstarter:in
302 Beiträge seit 2008
vor 14 Jahren

ich konnte mein problem mit dem standard binding (wsHttp) lösen.

folgender Link hat mir dabei sehr geholfen:
http://www.haveyougotwoods.com/archive/2008/03/29/wcf-and-large-messages.aspx

Besonder wichtig ist das die Einstellung der maximalen Übertragungsgröße serverseitig eingestellt wird. Also die BindingConfiguration muss manuell oder mit dem Editor hinzugefügt werden.

zuerst maxRequestLength:

  <system.web>
    <httpRuntime maxRequestLength="73400" />

und dann die BindingConfiguration:

 
<configuration>
...
...
...
<system.serviceModel>
    <services>
      <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="wsHttpBinding"  bindingConfiguration="WSTest" contract="WcfService1.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService1.Service1Behavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="WSTest"  closeTimeout="00:01:00"
  openTimeout="00:01:00"
  receiveTimeout="00:10:00"
  sendTimeout="00:01:00"
  maxReceivedMessageSize="73400320">
          <readerQuotas maxArrayLength="73400320" />
        </binding>
      </wsHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>