Friday, January 6, 2012

Note2Self: Configuring web service for web application usage

Entries to web.config in WSS/VirtualDirectories/80 to configure webservices
Steps:

1 Add 'endpoint' element to 'client':
<client>
   <endpoint address="http://localhost/YourService/ServicesYou.asmx"
             binding="basicHttpBinding"
             bindingConfiguration="###MyCustomBindingName1###"
             contract="###DefinedConfigurationName###"
             name="###stringEndPointConfigurationName###" />
</client>
###MyCustomBindingName1### -- is a reference to what will be added to the system.serviceModel/bindings/basicHttpBinding/ element. Preferably, prefix it with the binding type (i.e. in this case: "basicHttpBinding_MyCustomBindingName1")

###DefinedConfigurationName### -- should be the value that you defined in the Reference.CS file. To be more specific in the attribute before the interface definition:
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://WebServices/", ConfigurationName = "###DefinedConfigurationName###")]    
2 Create binding element
        <binding name="###MyCustomBindingName1###" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
I changed the maxReceivedMessageSize and maxBufferSize to the max. allowed size since I had trouble retrieving large DataTables.

No comments:

Post a Comment