Okay, let's tackle this:
First, you need to define a custom basicHttpBinding
binding configuration with some custom settings:
<bindings>
<basicHttpBinding>
<binding name="LargeSettings"
maxBufferSize="524288"
maxBufferPoolSize="524288"
maxReceivedMessageSize="6553600">
<readerQuotas maxDepth="32" maxStringContentLength="100000"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
This section needs to be in both your server-side's web.config, as well as your client side's config.
Secondly, on the server-side, you need to have a <services>
tag that defines your service and its endpoints and their configuration:
<services>
<service name="YourNamespace.YourClassName"
behaviorConfiguration="ServiceWithMetadata">
<endpoint name="Default"
address="http://localhost:53931/WCF/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="LargeSettings"
contract="YourNamespace.IServiceContract" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceWithMetadata">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
Points to check:
- your service name must be the fully qualified name (
YourNamespace.YourClassName
) of your service class - the class that implements your service contract
- your service contract in the endpoint must also be the fully qualified name of your service contract (
YourNamespace.IYourServiceContract
)
- the behaviorConfiguration of your
<service>
tag must reference and match exactly to the name=
attribute as defined in your <behaviors>
section
And thirdly, on the client side, you need something like this:
<client>
<endpoint name="Default"
address="http://localhost:53931/WCF/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="LargeSettings"
contract="ServiceReference.IYourService" />
</client>
You need to reference the endpoint defined in your service's definition on the server side, you need to use the same binding and binding configuration, and you need to use the service contract as defined in your service reference.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…