When you call the GetListItems method in Lists.asmx Web Service, you have to pass some XML parameters. These parameters are not well understood by the Web Service so the use of this Web Service can be difficult and maybe impossible.
XML parameters are written as strings in InfoPath window (I know that XML is just a string that follow some predefined rules).
This string which is encoded before pass it to the Web Service is no more understandable by the Web Service.
As the problem is find we can do some additional tests. Calling the Web Service from a .NET application can be done without any issue. According to this, there is a solution: create and use a Proxy Web Service (coded using the .NET platform) that will be deployed to SharePoint platform. This Proxy will convert the string to a real XML content.
<WebMethod()> _
Public Function GetListItems(ByVal listName As String, ByVal viewID As String, ByVal query As String, ByVal viewFields As String, ByVal rowLimit As String, ByVal queryOptions As String, ByVal webID As String) As XmlNode
Dim service As SharePointListsWS.Lists = GetWebServiceInstance(webID)
Dim queryElement As XmlNode = CreateNode("Query", query)
Dim viewFieldsElement As XmlNode = CreateNode("ViewFields", viewFields)
Dim queryOptionsElement As XmlNode = CreateNode("QueryOptions", queryOptions)
Return service.GetListItems(listName, viewID, queryElement, viewFieldsElement, rowLimit, queryOptionsElement, webID)
End Function
Private Function GetWebServiceInstance(ByVal webID As String) As SharePointListsWS.Lists
Dim service As New SharePointListsWS.Lists
service.Credentials = System.Net.CredentialCache.DefaultCredentials
service.Url = SPContext.Current.Web.Url + "/_vti_bin/Lists.asmx"
Return service
End Function
Private Function CreateNode(ByVal name As String, ByVal innerXml As String)
Dim document As New XmlDocument
Dim node As XmlNode = document.CreateElement(name)
node.InnerXml = innerXml
Return node
End Function
After having transform strings parameters to correct XML content, the Proxy Web Service will pass the XML parameters to Lists.asmx Web Service. This time GetListItems method is able to interpret the parameters. Values coming from the GetListItems method are returned directly to the client (in this case InfoPath).
If you want to code this Proxy Web Service, you have to know:
- How to code a Web Service;
- How to modify auto-generated elements to allow integration to SharePoint platform;
- How to add this Web Service to SharePoint platform.
There is a few articles about each of these topics. If you don’t want to do all these points, you can just install the attached Web Service: Download
It is quite easy as you just have to:
- Unzip the attached file;
- Click on install.bat.
Attention! Be aware that the actual version of this package will erase and replace spdisco.aspx file. When uninstall the Web Service the file is deleted. You should test it on test environment before put it in production. Furthermore, you should backup the file before any other operation.