Submitting Infopath to a .net Web Service
I have an infopath form and I am trying to submit the data to a Web Service. Now I created the form and a Web Service but it is not passing the values. Here is what I did....
First I extracted all the files from the form. I then ran the Visual Studio command prompt and ran this against the myschema.zsd file
xsd.exe myschem.xsd /classes /l:vb /n:InfoPathFormService
and this is the result of that
Option Strict Off
Option Explicit On
Imports System.Xml.Serialization
'
'This source code was auto-generated by xsd, Version=1.1.4322.2300.
'
Namespace InfopathFormService
'<remarks/>
<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-04-03T13:21:09"), _
System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-04-03T13:21:09", IsNullable:=false)> _
Public Class New_User
'<remarks/>
Public [New] As String
'<remarks/>
Public Change As String
'<remarks/>
Public Deletion As String
'<remarks/>
Public DateofRequest As String
'<remarks/>
Public FirstName As String
'<remarks/>
Public MiddleInitial As String
'<remarks/>
Public Suffix As String
'<remarks/>
Public StreetAddress As String
'<remarks/>
Public State As String
'<remarks/>
Public Zip As String
'<remarks/>
Public HomePhone As String
'<remarks/>
Public CellPhone As String
'<remarks/>
<System.Xml.Serialization.XmlElementAttribute("AlternateE-MailAddress")> _
Public AlternateEMailAddress As String
'<remarks/>
Public DistributionGroups As String
'<remarks/>
Public Branch As String
'<remarks/>
Public Department As String
'<remarks/>
Public Title As String
'<remarks/>
Public JobFunction As String
'<remarks/>
Public ManagersName As String
'<remarks/>
Public BranchPhoneNumber As String
'<remarks/>
Public BranchFAXNumber As String
'<remarks/>
Public ExpectedStartDate As String
'<remarks/>
Public TerminationDate As String
'<remarks/>
Public ManagersPhone As String
'<remarks/>
<System.Xml.Serialization.XmlElementAttribute("ManagersE-mail")> _
Public ManagersEmail As String
'<remarks/>
Public NewHireChecklistCompleted As String
'<remarks/>
Public ERPAccountingAccess As String
'<remarks/>
Public ERPB2BAccess As String
'<remarks/>
Public ERPServiceCenterAccess As String
'<remarks/>
Public ERPApprovalEmail As String
'<remarks/>
Public ApproveReject As String
'<remarks/>
Public Comment As Comment
'<remarks/>
Public signatures2 As signatures2
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public LastName As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public DesktopPC As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public LaptopPC As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public ThinClient As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public P21 As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public P21Play As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Outlook As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public PumpApplications As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Engineering As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Sales As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Accounting As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public IMP As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Operations As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public InformationTechnology As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public P21RoleName As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public OutsideSalesrepNumber As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public B2BEmployee As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public CashDrawer As String
'<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public AccesstoOutlook As String
'<remarks/>
<System.Xml.Serialization.XmlAnyAttributeAttribute()> _
Public AnyAttr() As System.Xml.XmlAttribute
End Class
'<remarks/>
<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-04-03T13:21:09"), _
System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-04-03T13:21:09", IsNullable:=false)> _
Public Class Comment
'<remarks/>
<System.Xml.Serialization.XmlTextAttribute(), _
System.Xml.Serialization.XmlAnyElementAttribute()> _
Public Any() As System.Xml.XmlNode
End Class
'<remarks/>
<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-04-03T13:21:09"), _
System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-04-03T13:21:09", IsNullable:=false)> _
Public Class signatures2
'<remarks/>
<System.Xml.Serialization.XmlAnyElementAttribute()> _
Public Any() As System.Xml.XmlElement
End Class
End Namespace
i then have a webmethod that looks like this
<WebMethod()> Public Function SubmitForm(ByVal myFields As InfopathFormService.New_User) As String
'I defined Variables here but my message was too long so I excluded them.
''New, Change or Delete User
new_user = myFields.[New]
edit_user = myFields.Change
del_user = myFields.Deletion
requestdate = myFields.DateofRequest
''New User information
l_name = myFields.LastName
f_name = myFields.FirstName
initial = myFields.MiddleInitial
suffix = myFields.Suffix
address = myFields.StreetAddress
state = myFields.State
zip = myFields.Zip
h_phone = myFields.HomePhone
c_phone = myFields.CellPhone
email = myFields.AlternateEMailAddress
Dim strsql As String
strsql = " INSERT INTO Blah Blah Blah"
Try
conn.Open()
Dim cmd As SqlCommand = New SqlCommand(strsql, conn)
cmd.CommandText = strsql
cmd.ExecuteNonQuery()
Catch ex As Exception
End Try
End Function
End Class
Unfortunately every variable ends up being nothing. I am not sure what I did wrong or if there is a better way to accomplish my goal. All thoughts are welcome