Skip to content

Create webservice proxy in PowerShell to Sharepoint fails “lists.asmx was not recognized” and .. lists.asmx?disco not found


Suddenly after a maintenance weekend the powershell scripts failed that work with Sharepoint 2010 list services and nobody had changed any thing.
The error was:

New-WebServiceProxy : The document at the url was not recognized as a known document type.

The error message from each known type may help you fix the problem: - Report from is The document format is not recognized (the content type is 'text/html; charset=utf-8')

- Report from 'DISCO Document' is 'There was an error downloading '' .

- The request failed with HTTP status 404: Not Found.

- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=utf-8').'.

- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=utf-8').'

 At C:\script\SProutines.ps1:98 char:29 + $obj = New-WebServiceProxy <<<< -Uri $ServiceAtListURL -Namespace $namespace -UseDefaultCredential 

+ CategoryInfo : InvalidOperation: ( -..._bin/lists.asmx:Uri) [New-WebServiceProxy], InvalidOperationException + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.NewWebServiceProxy Cannot create Web Proxy from ""

At C:\script\SProutines.ps1:100 char:9 + throw <<<< "Cannot create Web Proxy from ""$ServiceAtListURL""" + CategoryInfo : OperationStopped: (Cannot create W...bin/lists.asmx":String) [], RuntimeException + FullyQualifiedErrorId : Cannot create Web Proxy from ""

The scripts use following functionality:

$siteCollectionURL = ""
$subsite = "web1"
$Listname = "aList" ...
# create webservice proxy
$PathSubSiteSVClist = ("{0}/{1}/{2}" -f $SiteCollectionURL, $Subsite, "_vti_bin/lists.asmx").replace('\','/').replace('//','/').replace(':/','://')
# $PathSubSiteSVClist becomes
# ""
$wsp = GetWebService -namespace wsSP -type "lists" -ServiceAtListURL $PathSubSiteSVClist

The GetWebService function which was fully functional until “nothing happend on the maintanance weekend” is: …

# Try to create the object first as the namespace may be there already
try {$obj = New-Object -TypeName "$namespace.$type" }
catch {         # Create the proxy and try again.        
         # This should not require special permissions
          $obj = New-WebServiceProxy -Uri $ServiceAtListURL -Namespace $namespace -UseDefaultCredential
          if($obj -eq $null) {
               throw "Cannot create Web Proxy from ""$ServiceAtListURL"""
$obj.Url = $ServiceAtListURL
$obj.UseDefaultCredentials = $true


This is all standard stuff you find everywhere on the web. This suddenly stop working (ran from different machines , against different site collections – running for a different farm still worked). The workaround: Use a different Url to create the proxy. Extend the serive urls with “?wsdl” . But only when creating the service. All other usages of the url stay the same: the code in the try block is now:

$error.removeat(0) $obj = New-WebServiceProxy -Uri (“{0}?wsdl” -f $ServiceAtListURL) -Namespace $namespace -UseDefaultCredential

Thanks and credits go to Nick Grattan, who bloged about this error on SP2007

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: