SPWebProxy response limit – Increasing It!

What a week of ups and downs! 

First, an UP, I build a cool app for everyone to use (the SP REST tool – http://sprest.architectingconnectedsystems.com), then decided the CSOM XML generation is helpful, but not helpful enough.  I have ported most of the code to support the SharePoint App model (specifically provider hosted), but then the DOWN.  So many configuration limitations for a provider hosted app, eek. 

 So, whatever, I get the code working and write a cool little auth post (https://blogs.architectingconnectedsystems.com/blogs/cjg/archive/2014/01/22/Office-and-SharePoint-App-Model-Authentication-_2D00_-Plain-and-Simple_2100_.aspx) = UP.  I decide that there has to be more to SharePoint App hosted and why can't that work?  I research more into this little tidbit about the SPWebProxy endpoint you can use with your Apps (http://msdn.microsoft.com/en-us/library/office/fp179895.aspx?ppud=4).  I think sweet!  Let's try that…bummer…DOWN…limit of 200K on the response. WTH.

So…as with anything, I never take no for an answer.  Limits?  I say screw limits!  Looking at the code, there is a lovely little object called SPWebProxyConfig.  All of its methods and properties are PUBLIC.  Including our little friend, maxResponseSize. Muahahaha!  An UP moment.  But it doesn't last too long…because…a DOWN.  BUG found in the code.  They never call the Update() method on the SPWebProxyConfig object as part of the initialization, therefore, it doesn't get saved to the Config database.  That means they are grabbing the parent (ContentService) for no reason, searching for its children and *never* finding it.  So bummed.  It is a bug, simple over sight on the coding aspect.  I'm sure this will get fixed (I'll make sure of it).  So here is how to get the object persisted so you can change the request size – UP!:

$contentService =
[Microsoft.SharePoint.Administration.SPWebService]::ContentService
$type = $contentService.gettype()
$config = new-object Microsoft.SharePoint.SPWebProxyConfig
$configType = $config.gettype()
$methods = $Type.GetMethods() | where-object {$_.Name -eq "GetChild"}
$gm = $methods[1].MakeGenericMethod($configType)
$realConfig = $gm.Invoke( $contentService , $null)
if ($realConfig -eq $Null)
{
$config.update()
$realConfig = $gm.Invoke( $contentService , $null)
}
$realConfig.MaxResponseSize = 400000  #this is an Integer so up to 2GB
$realConfig.update()

 

So…this can only be done on-premise, and cannot be modified in O365.  Therefore if you are on-prem, you guys and gals stay in UP mode, if you are O365, you switch to DOWN!

Proxy away unlimited my fellow SharePoint App hosted on-prem App builders!
Chris