I'm attempting to create the Lists WebService example in Chapter 2 using the "Customers" list. I receive this error:
System.Web.Services.Protocols.SoapException was caught
Actor=""
Lang=""
Message=Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerExcepti on' was thrown.
Node=""
Role=""
Source=System.Web.Services
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[] parameters)
at WPFListApp.MYSPWebReference.Lists.GetListAndView(S tring listName, String viewName) in C:\Users\Administrator\documents\visual studio 2010\projects\WPFListApp\WPFListApp\Web References\MYSPWebReference\Reference.
vb:line 262
at WPFListApp.MainWindow.btnUpdate_Click(Object sender, RoutedEventArgs e) in C:\Users\Administrator\documents\visual studio 2010\projects\WPFListApp\WPFListApp\MainWindow.xam l.
vb:line 68
InnerException:
I thought this may be a null error because the line throwing the error is:
Dim myListView As XmlNode = myListService.GetListAndView("Customers", "")
the "myListService" is null. I changed the security line to:
myListService.Credentials = New NetworkCredential("username", "password")
maybe the default credentials that the example provided was incorrect. Unfortunately, that change generated a "401" error. Does anyone have any ideas how to resolve the issue?
<code>
Try
strCompanyName = txtCompanyName.Text
strRegion = txtRegion.Text
strSize = txtSize.Text
strSales = "$" + txtSales.Text
Dim myListService As MYSPWebReference.Lists = New MYSPWebReference.Lists()
myListService.Credentials = System.Net.CredentialCache.DefaultCredentials
myListService.Url = "http://localhost/_vti_bin/Lists.asmx"
Dim myListView As XmlNode = myListService.GetListAndView("Customers", "")
strListID = myListView.ChildNodes(0).Attributes("Name").Value
strViewID = myListView.ChildNodes(1).Attributes("Name").Value
Dim myListDoc As New XmlDocument()
Dim batchXML As XmlElement = myListDoc.CreateElement("Batch")
batchXML.InnerXml = "<Method ID = '1' Cmd='New'><Field Name='Title'>" & strCompanyName & "</Field><Field Name='Region'>" & strRegion & "</Field><Field Name='Size'>" & strSize & "</Field><Field Name='Sales'>" & strSales & "</Field>" & "</Method>"
Dim myListReturn As XmlNode = myListService.UpdateListItems(strListID, batchXML)
MessageBox.Show("SharePoint List was updated!")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
</code>
Thanks in advance.
C.