SR1092 SR1092 - 1 year ago 72 Question

How to pass multiple values to web service in

I have created a form in, where on-click of a button multiple variables are passed to a web service. My code is as below :

Imports MySql.Data.MySqlClient
Imports OutlookAddIn2.mantistest
Dim QService As New MantisConnectPortTypeClient

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim value1 As String
Dim value2 As String
Dim value3 As String
Dim value4 As String
Dim viewstate As String

value1 = Project_Name.SelectedItem.ToString()
value2 = ComboBox2.SelectedItem.ToString()
value3 = ComboBox3.SelectedItem.ToString()
value4 = TextBox4.Text
Dim s As String = String.Format("Value 1: {0} value2 : {1} value3: {2} value4: {3}", value1, value2, value3, value4)

TextBox1.Text = QService.mc_issue_add(username:="**", password:="**", issue:="view_state:{0} project{1}")

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 :
    issue:=("Category:{0} project{1}",value1, value2)

    Error :
    saying that a named argument is expected.

  2. Code :
    TextBox1.Text = QService.mc_issue_add(username:="**", password:="**", view_state:=value1, Project:=value2)

    Error : Argument not specified for parameter
    of public function
    QService.mc_issue_add(Username as String, Password as String, issue as mantistest.Issuedata)As string

Where have I gone wrong? I have tried using other arguments with single input values and it works fine. Appreciate any assistance.

Answer Source

I had to describe the fields separately like this

    Dim mantNote As IssueData
    mantNote = New IssueData

    Dim idField As String
    idField = " "

    Dim view_stateField As ObjectRef
    view_stateField = New ObjectRef = 10 = " "

    Dim last_updatedField As Date
    last_updatedField = Date.FromOADate(6 / 6 / 2016)

    Dim projectField As ObjectRef
    projectField = New ObjectRef = 1 = "test"

    Dim categoryField As String
    categoryField = "test"

and add them under 1 description = idField
    mantNote.view_state = view_stateField
    mantNote.last_updated = last_updatedField
    mantNote.project = projectField
    mantNote.category = categoryField
    TextBox1.Text = QService.mc_issue_add(username:=" ", password:=" ", issue:=mantNote)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download