STS: Procedure to Programmatically Connect MSXML 4.0 to SharePoint Portal Server Is Not Successful (321015)



The information in this article applies to:

  • SharePoint Team Services from Microsoft
  • Microsoft SharePoint Portal Server 2001 SP1

This article was previously published under Q321015

SYMPTOMS

If you try to programmatically configure MSXML 4.0 to connect to SharePoint Portal Server, the procedure is unsuccessful.

CAUSE

This behavior occurs because SharePoint Portal Server (SPS) is not compatible with MSXML 4.0. Specifically, the ServerXMLHTTP object cannot be used to connect to an SPS server.

WORKAROUND

To work around this issue, use "Msxml2.XMLHTTP.4.0" instead of "Msxml2.ServerXMLHTTP.4.0" in your code (see the "More Information" section of this article). Or, use MSXML 3.0 to connect to SPS.

MORE INFORMATION

This issue occurs because SPS is not fully HTTP 1.1-compliant. SPS inserts an extra CRLF character in chunked content encoding, in violation of the RFC. This extra CRLF character confuses Windows HTTP 5.0. The following Microsoft Visual Basic code illustrates this problem:
main
'Reference: Microsoft XML, v4.0
Private Sub Main()

Dim strRequest
Dim m_xh ' As msxml2.ServerXMLHTTP

Dim Server
Dim Name
Dim Password

'TODO: Change these three lines
Server = "MySPSServer"
Folder = "MyWorkspace"
URL = "http://" & Server & "/" & Folder
Name = "Domain\Account"
Password = "password"

strRequest = "<?xml version=""1.0""?>" & vbCrLf & "<a:searchrequest xmlns:a=""DAV:"">" & vbCrLf
strRequest = strRequest & "<a:sql>" & vbCrLf & "select ""DAV:href""" & vbCrLf
strRequest = strRequest & " From Scope(" & "'DEEP TRAVERSAL OF """  & URL & """')"
strRequest = strRequest & vbCrLf & " </a:sql>" & vbCrLf & "</a:searchrequest>"

Set m_xh = CreateObject("Msxml2.ServerXMLHTTP.4.0")

m_xh.Open "SEARCH", URL, False, Name, Password

m_xh.SetRequestHeader "content-Type","Text/xml"
m_xh.send strRequest

MsgBox m_xh.responseText

If Err.Number Then MsgBox ("Error: " & Hex(Err.Number) & ": " & Err.Description)
End Sub
				

Modification Type:MinorLast Reviewed:3/4/2004
Keywords:kbprb KB321015