Soumya Rao

Soumya Rao

  • NA
  • 6
  • 4.3k

How to pass multiple values to web service in VB.net

May 27 2016 3:38 AM
I have created a form in VB.net, where on-click of a button multiple variables are passed to a web service. My code is as below :
  1. Imports MySql.Data.MySqlClient  
  2. Imports OutlookAddIn2.mantistest  
  3. Dim QService As New MantisConnectPortTypeClient  
  4.   
  5. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click  
  6. Dim value1 As String  
  7. Dim value2 As String  
  8. Dim value3 As String  
  9. Dim value4 As String  
  10. Dim viewstate As String  
  11.   
  12.   
  13. value1 = Project_Name.SelectedItem.ToString()  
  14. value2 = ComboBox2.SelectedItem.ToString()  
  15. value3 = ComboBox3.SelectedItem.ToString()  
  16. value4 = TextBox4.Text  
  17. Dim s As String = String.Format("Value 1: {0} value2 : {1} value3: {2} value4: {3}", value1, value2, value3, value4)  
  18. Windows.Forms.MessageBox.Show(s)  
  19.   
  20. TextBox1.Text = QService.mc_issue_add(username:="**", password:="**", issue:="view_state:{0} project{1}")  
  21.   
  22. End Sub  
 
The input parameters of my web service are :
  1. Project
  2. Category
  3. Priority
  4. Status
When I try to put them in following ways I get the following errors :
  1. Code : 
    1. issue:=("Category:{0} project{1}",value1, value2)   
    • Error : value1 saying that a named argument is expected.
  2. Code : 
    1. TextBox1.Text = QService.mc_issue_add(username:="**", password:="**", view_state:=value1, Project:=value2)   
    • Error : Argument not specified for parameter issue of public function QService.mc_issue_add(Username as String, Password as String, issue as mantistest.Issuedata)As string
This is the function for that particular module in the webservice
  1. Function mc_issue_add(ByVal username As StringByVal password As StringByVal issue As mantistest.IssueData) As <System.ServiceModel.MessageParameterAttribute(Name:="return"), System.Xml.Serialization.SoapElementAttribute(DataType:="integer")> String  
 
Where have I gone wrong? I have tried using other arguments with single input values and it works fine. Appreciate any assistance.

Answers (1)