SoapServerException Error - InfoPath Dev
in

InfoPath Dev

SoapServerException Error

Last post 10-27-2006 06:33 PM by jimbob. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-26-2006 12:40 PM

    • Afzal
    • Not Ranked
    • Joined on 10-26-2006
    • USA
    • Posts 14

    SoapServerException Error

    I am trying to add an item in the custom list on the sharepoint site from an InfoPath form but it is giving me an error:

    Message: "Exception of type Microsoft.SharePoint.SoapServer.SoapServerException was thrown."
    Source: "System.Web.Services"
    StackTrace: "at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
    at lists.Lists.UpdateListItems(String listName, XmlNode updates) in C:\PIB2\Sample\SubmittoList\Web References\lists\Reference.vb:line 205
    at SubmittoList.SubmittoList.CreateStatusHistory_Ex(String strTitle, String strProject, String dtIssueDate, String strIssueStatus) in C:\PIB2\Sample\SubmittoList\FormCode.vb:line 142"

    Code:


    Dim resultError As XmlNode

    Dim sBatch As String = ""
    Dim oListWS As New lists.Lists
    Dim ListName As String

    oListWS.Credentials = System.Net.CredentialCache.DefaultCredentials


    sBatch = "<Method ID=""1"" Cmd=""New"">"
    sBatch += "<Field Name=""Title"">![CDATA[" + strTitle + "]]</Field>"
    sBatch += "<Field Name=""Project"">![CDATA[" + strProject + "]]</Field>"
    sBatch += "<Field Name=""StatusDate"">![CDATA[" + dtIssueDate + "]]</Field>"
    sBatch += "<Field Name=""Status"">![CDATA[" + strIssueStatus + "]]</Field>"
    sBatch += "</Method>"

    Dim xDoc As New System.Xml.XmlDocument
    Dim xBatch As System.Xml.XmlElement = xDoc.CreateElement("Batch")

    xBatch.SetAttribute("OnError", "Continue")
    xBatch.SetAttribute("ListVersion", "1")
    xBatch.SetAttribute("PreCalc", "TRUE")
    xBatch.SetAttribute("ViewName", "15A7D8ED-F094-45F6-9964-CDF0E6DE26D0")
    xBatch.InnerXml = sBatch

    Try
    Dim xReturn As System.Xml.XmlNode = oListWS.UpdateListItems("", xBatch)

    MsgBox(xReturn.OuterXml)


    Catch ex As Exception

    MsgBox(vbCrLf + "Exception: " + vbCrLf + ex.Message + ex.StackTrace + ex.Source)

    End Try
  • 10-27-2006 12:08 AM In reply to

    Re: SoapServerException Error

    What is at line 142?
    Patrick Halstead
    Project Manager at Qdabra
  • 10-27-2006 11:25 AM In reply to

    • Afzal
    • Not Ranked
    • Joined on 10-26-2006
    • USA
    • Posts 14

    Re: SoapServerException Error

    Hi Patrick,

    I am using the sample example given in your book "Developing solutions with MS InfoPath" on Page # 296 and I am getting the following error message:

    Object reference not set to an instance of an object.
    at SubmitExample.SubmitExample.CreateTask(String strTitle, String strProject, String strIssueDate, String strIssueStatus) in C:\PIB2\Sample\SubmitExample\FormCode.vb:line 114
    at SubmitExample.SubmitExample.CTRL3_5_OnClick(DocActionEvent e) in C:\PIB2\Sample\SubmitExample\FormCode.vb:line 131
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    Below is my code that I am using to insert a new list item in sharepoint list:


    Public Function CreateTask(ByVal strTitle As String, ByVal strProject As String, ByVal strIssueDate As String, ByVal strIssueStatus As String) As Integer

    Dim listName As String
    Dim listservice As lists.Lists
    Dim node As XmlDocument
    Dim res As XmlNode
    Dim resultError As XmlNode
    Dim resultId As XmlNode


    'listName = "{33533BB8-132E-4C92-BA97-5748C43F67BE}"
    listservice = New lists.Lists
    listservice.Credentials = System.Net.CredentialCache.DefaultCredentials

    node = New XmlDocument

    node.LoadXml("" _
    + "<Batch OnError='Continue' Listversion='1' xmlns=''>" _
    + " <Method ID='1' Cmd='New'>" _
    + " <Field Name='IssueTitle'>" + strTitle + "</Field>" _
    + " <Field Name='Project'>" + strProject + "</Field>" _
    + " <Field Name='IssueDate'>" + strIssueDate + "</Field>" _
    + " <Field Name='IssueStatus'>" + strIssueStatus + "</Field>" _
    + " </Method>" _
    + "</Batch>")

    res = listservice.UpdateListItems("{9CA2107C-CD11-4CA0-8F3F-1921F49100EF}", node)

    Dim nsmgr As XmlNamespaceManager
    nsmgr = New XmlNamespaceManager(res.OwnerDocument.NameTable)
    nsmgr.AddNamespace("s", "http://schemas.microsoft.com/sharepoint/soap")
    nsmgr.AddNamespace("z", "#RowsetSchema")

    resultError = res.SelectSingleNode("s:Result[@ID='1,New']/s:ErrorCode", nsmgr)

    If (resultError Is Nothing Or Convert.ToInt32(resultError.InnerText, 16) <> 0) Then
    Return 0
    End If

    resultId = res.SelectSingleNode("s:Result[@ID=""1,New""]/z:row/@ows_ID", nsmgr)
    Return Integer.Parse(resultId.InnerText)

    End Function

    ' The following function handler is created by Microsoft Office InfoPath. Do not
    ' modify the type or number of arguments.
    <InfoPathEventHandler(MatchPath:="CTRL3_5", EventType:=InfoPathEventType.OnClick)> _
    Public Sub CTRL3_5_OnClick(ByVal e As DocActionEvent)
    ' Write your code here.

    Dim id As Integer
    id = CreateTask(thisXDocument.DOM.selectSingleNode("/my:myFields/my:IssueTitle").text, thisXDocument.DOM.selectSingleNode("/my:myFields/my:Project").text, thisXDocument.DOM.selectSingleNode("/my:myFields/my:IssueDate").text, thisXDocument.DOM.selectSingleNode("/my:myFields/my:IssueStatus").text)

    If (id = 0) Then
    thisXDocument.UI.Alert("Failed to create task")
    Else
    thisXDocument.UI.Alert("Created task with ID " + id.ToString + ".")
    End If


    End Sub

    Red bold is the line 114 where I am getting this error.

    Any help is appreciated.

    Thanks,

  • 10-27-2006 06:33 PM In reply to

    • jimbob
    • Top 500 Contributor
    • Joined on 11-26-2004
    • USA
    • Posts 32

    Re: SoapServerException Error

    There is an 'Or' that should be 'OrElse' in the last If statement:
    It should be:
    If (resultError Is Nothing OrElse Convert.ToInt32(resultError.InnerText, 16) <> 0) Then
    Return 0
    End If

    The 'Or' and 'And' operations do not shortcut. You must use 'AndAlso' and 'OrElse' to use shortcut operations (similar to how && and || in C#/C++ work)
    Jim Cantwell
    InfoPathDev - Redmond
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.