The C-Sharp client project demonstrates using the Web Service Operations created by the MVS ToolKit.
C-Sharp client examples are located in the <MVS.install.dir>\samples\mv-ws-vc\ folder of your installation.
The Add Web Reference dialog box displays.
http://localhost:8181/mvs?wsdl
The Web Service is listed under the Web References node in the Solution Explorer.
Note that the Service URL is displayed from the service WSDL. This can be changed here or in the associated exe.config file before starting the application.
The application calls the Web Service and displays the results in the grid.
The search-inventory service is called by the search command button event handler:
private void btnSearch_Click(object sender, EventArgs e) { try { mvs.mvsService mvsService = new mvs.mvsService(); mvsService.Url = txtURL.Text; mvs.searchinventory searchInventory = new mvs.searchinventory(); searchInventory.DESC = "[" + txtDescription.Text + "]"; mvs.searchinventoryResponse response = mvsService.searchinventory(searchInventory); mvs.searchinventoryRow[] rows = response.searchinventoryRowSet; String[] gridRow = new String[6]; dataGridSearchInventoryResults.Rows.Clear(); foreach (mvs.searchinventoryRow row in rows) { for (int i = 0; i < row.ID.Length; i++) { gridRow[0] = row.ID[i][0]; gridRow[1] = row.DESCRIPTION[i][0]; gridRow[2] = row.RETAILPRICE[i][0]; gridRow[3] = row.PROMOPRICE[i][0]; gridRow[4] = row.QTYONHAND[i][0]; gridRow[5] = row.TYPE[i][0]; } dataGridSearchInventoryResults.Rows.Add(gridRow);} } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error accessing web services", MessageBoxButton.RetryCancel, MessageBoxIcon.Error); } }
The item is displayed in the Response text box.
The check-inventory service is called by the execute command button event handler:
private void btnExecute_Click(object sender, EventArgs e) { try { mvs.mvsService mvsService = new mvs.mvsService(); mvsService.Url = txtURK.Text; mvs.checkinventory checkInventory = new mvs.checkinventory(); checkInventory.ITEMID = txtItemID.Text; mvs.checkinventoryResponse response = mvsService.checkinventory(checkInventory); txtResponse.Text = response.ITEM; } catch (Exception exception) { MessageBox.Show(exception.Message, "Error accessing web services", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } }
The search-inventory-by-location service is called by the execute command button event handler:
private void btnCheckInventory_Click(object sender, EventArgs e) { try { mvs.mvsService mvsService = new mvs.mvsService(); mvsService.Url = txtURL.Text; mvs.checkinventorybylocation checkInventoryByLocation = new mvs.checkinventorybylocation(); String [] idList = txtItemIDs.Text.Replace("\r\n", ",").Split(','); String [] locationList = txtLocations.Text.Replace("\r\n", ",").Split(','); // Set the locations array // ----------------------- mvs.locations[] locations = new mvs.locations[locationList.Length]; for (int i = 0; i < locationList.Length; i++) { locations[i] = new mvs.locations(); locations[i].locationname = locationList[i]; } // Set the items array // ------------------- mvs.items[] items = new mvs.items[idList.Length]; for (int i = 0; i < idList.Length; i++) { items[i] = new mvs.items(); items[i].itemid = idList[i]; items[i].locations = locations; } // Create the inventory request and set it's values // ------------------------------------------------ mvs.inventoryrequest request = new mvs.inventoryrequest(); request.customerid = "123"; request.items = items; checkInventoryByLocation.REQUEST = request; mvs.checkinventorybylocationResponse response =
mvsService.checkinventorybylocation(checkInventoryByLocation); mvs.items1[] result = response.inventoryresponse.items; String[] gridRows = new String[10]; dataGridSearchInventoryByLocationResults.Rows.Clear(); for (int i = 0; i < result.Length; i++) { mvs.inventory[] inventory = result[i].inventory; for (int j = 0; j < inventory.Length; j++) { if (j == 0) { gridRows[0] = result[i].itemid; gridRows[1] = result[i].description; gridRows[2] = result[i].listprice.ToString(); gridRows[3] = result[i].saleprice.ToString(); } else { gridRows[0] = ""; gridRows[1] = ""; gridRows[2] = ""; gridRows[3] = ""; } gridRows[4] = inventory[j].locationid; gridRows[5] = inventory[j].locationname; gridRows[6] = inventory[j].qtyonhand.ToString(); dataGridSearchInventoryByLocationResults.Rows.Add(gridRows); } } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error accessing web services", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } }
The items are displayed in the grid.
The list-customers service is called by the execute command button event handler:
private void cmdExecuteListCustomers Click(object sender, EventArgs e) } try { mvs.mvsService mvsService = new mvs.mvsService(); mvsService.Url = txtURL.Text; mvs.listcustomers listcustomers = new mvs.listcustomers(); listcustomers. STATE = txtState.Text; mvs.mvslistcustomersResponse response = mvsService.listcustomers(listcustomers); mvs.mvslistcustomersRow[] rows = response.mvslistcustomersRowSet; String(' gridRow = new String[6]; dataGridCustomers.Rows.Clear(); foreach (mvs.mvslistcustomersRow row in rows) { for (int i = 0; i < row.CUSTOMERID.Length; i++) { gridRow[0] = row.CUSTOMERID[i][0]; gridRow[1] = row.ORGANIZATIONNAME[i][0]; String address = row.ADDRESS[i][0] + "," + row.CITY[i][0] + ", " + row.STATE[i][0] + " " + row.POSTALCODE[i][0]; gridRow[2] = address; gridRow[3] = row.PHONENUMBER[i][0]; gridRow[4] = row.CONTACTNAME[i][0]; } dataGridCustomers.Rows.Add(gridRow); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error accessing web services", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } }
The quote service is called by the execute command button event handler:
private void btnExecuteQuote_Click(object sender, EventArgs e) { try { mvs.mvsService mvsService = new mvs.mvsService(); mvsService.Url = txtURL.Text; mvs.quote quote = new mvs.quote(); quote.SYMBOLS = txtSymbol.Text; mvs.mvsquoteResponse response = mvsService.quote(quote); dataGridQuote.Rows.Clear(); char am = (char)254; String [] name = response.COMPANYNAMES.Split(am); String() price = response.PRICES.Split(am); String(' change = response.CHANGEAMTS.Split(am); String[' lastTrade = response.LASTTRADES.Split(am); String(' volume = response.VOLUMES.Split(am); String(' avgVolume = response.AVGVOLUMES.Split(am); String(' gridRow = new String[10]; for (int i = 0; i < name.Length; i++) { gridRow[0] = name[i]; gridRow[1] = price[i]; gridRow[2] = change[i]; gridRow[3] = lastTrade[i]; gridRow[4] = volume[i]; gridRow[5] = avgVolume[i]; dataGridQuote.Rows.Add(gridRow); } } catch (Exception exception) { MessageBox.Show(exception.Message, "Error accessing web services", I4essageBoxButtons.RetryCancel, MessageBoxlcon.Error); } }