0
votes

I am getting this error while passing byte[] to WCF. Can someone plz solve this error??

Configuration at Service(web.config)

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <system.serviceModel>
        <bindings>
   <basicHttpBinding>
    <binding name="NewBinding0" maxBufferSize="2097151" maxBufferPoolSize="2097151"
     maxReceivedMessageSize="2097151" messageEncoding="Mtom"
     transferMode="Streamed">
     <readerQuotas maxDepth="2097151" maxStringContentLength="2097151"
      maxArrayLength="2097151" maxBytesPerRead="2097151" maxNameTableCharCount="2097151" />
    </binding>
   </basicHttpBinding>
   <mexHttpBinding>
    <binding name="higherMessageSize_MEX" />
   </mexHttpBinding>
  </bindings>
  <client>
   <endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding0"
    contract="LService.IService">
    <identity>
     <dns value="localhost" />
    </identity>
   </endpoint>
   <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="higherMessageSize_MEX"
    contract="IMetadataExchange" />
  </client>
  <behaviors>
            <serviceBehaviors>
                <behavior>
                    <!-- 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="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
</configuration>

Configuration at WPF application (app.config)

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="2097151" maxBufferPoolSize="2097151" maxReceivedMessageSize="2097151"
                    messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="2097151" maxStringContentLength="2097151"
                        maxArrayLength="2097151" maxBytesPerRead="2097151" maxNameTableCharCount="2097151" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:5980/LService/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
                contract="LService.IService" name="BasicHttpBinding_IService" />
        </client>
    </system.serviceModel>
</configuration>
1
If you post code, XML or data samples, please highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar to nicely format and syntax highlight it!marc_s
What does your service contract look like?? How are you calling that service from your client?? How did you create the client-side proxy (svcutil? Add Service Reference??)marc_s

1 Answers

2
votes

Without knowing your service contract and all the details needed - I can only speculate.

What strikes me is that your server-side config doesn't contain any configuration for a <service>.

The rule is this:

  • on the server side, you need a <services> tag in your config, which contains any number of <service> tags, which defines each service on that server. Each <service> tag in turn can contain any number of <endpoint> tags to define one or multiple service endpoints

  • on the client, you have one or multiple <client> entries, each of which contains a single <endpoint> that defines what service address your client connects to

So your server side config should look something like this:

<system.serviceModel>
   <bindings>
      <basicHttpBinding>
          <binding name="NewBinding0" ....... />
      </basicHttpBinding>
      .....
   </bindings>
   <services>
       <service name="YourNamespace.YourService"
                behaviorConfiguration="Default" >
           <endpoint name="BasicEndpoint"
               address="http://localhost:5757/Services"
               binding="basicHttpBinding"
               bindingConfiguration="NewBinding0"
               contract="YourNamespace.IYourServiceContract" />
       </service>
   </services>
   <behaviors>
      <serviceBehaviors>
         <behavior name="Default">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
         </behavior>
      </serviceBehaviors>
   </behaviors>
   ......
</system.serviceModel>

Your client-side config seems fine - except of course, you have to put the address of your server where the service lives into the address= attribute - that typically isn't localhost