I have a proxy application that pass the same functionality outside of our corp network. It consumes internal web service (ASMX) through SSL required and opens through SharePoint web service port. It pops up the following error when I added some new functions which supposed to hit the default max limit. There a bunch solutions from internet and basically, most of them are targeting the configuration file (app.xml etc). As the proxy application is consuming the web service through encapsulated internal layer. So the solution that finally solved the issue is via the code. Here lists the proxy call function that specify the max limit value (2147483647).
Error:
The maximum nametable character count quota (16384) has been exceeded while reading XML data.Solution function:
Public Shared Function SecureProxyCall(Of T)(targetUrl As String, programaticUserID As String, programaticPassword As String, domain As String) As T
Dim binding As New BasicHttpBinding()
Dim timeout As New TimeSpan(0, 20, 0)
binding.MaxReceivedMessageSize = 2147483647
binding.MaxBufferSize = 2147483647
binding.ReaderQuotas.MaxStringContentLength = 2147483647
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647
binding.SendTimeout = timeout
binding.ReceiveTimeout = timeout
Dim address As New EndpointAddress(targetUrl)
Dim securedClient = Activator.CreateInstance(GetType(T), New Object() {binding, address})
If String.IsNullOrEmpty(programaticUserID) Then
'Force to anonymous
binding.Security.Mode = BasicHttpSecurityMode.None
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None
Else
binding.Security.Mode = BasicHttpSecurityMode.Transport
securedClient.ClientCredentials.Windows.ClientCredential = New Net.NetworkCredential(programaticUserID, programaticPassword, "nfm")
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows
End If
Return securedClient
End Function
No comments:
Post a Comment