我有一个 Web 服务,但需要知道如何在 Windows 应用程序表单中对其进行测试。
这是服务的开始。我会将表单代码放在按钮中,还是将其返回标签?并没有完全理解到 c# 或 .net 我已经成功调用了 Web 服务,只需要返回字符串以确保加密工作正常。
<%@ WebService Language="C#" Class="UserEncryptionLink.EncryptUserLink" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Schema;
using System.Xml.Serialization;
using System.Text;
using System.Security.Cryptography;
namespace UserEncryptionLink
{
/// <summary>
/// This Web Service is to encrypt user details and display them in the URL when they click on a link taking them to InfoExchange
/// </summary>
[WebService(Namespace = " Webspace name")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
//To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class EncryptUserLink : System.Web.Services.WebService
{
[WebMethod]
public void TestCypher()
{
var key = "12345";
var vector = "12345";
var username = "YOURDOMAIN\\YOURUSERNAME";
var url = "sitename.com";
var it = GetSingleSignOnUrl(url, username, key, vector);
}
还有我的表格
是的,我的表单引用了该服务,它看起来像这样。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FormForEncrypt.nameofURL;
using System.Net;
namespace FormForEncrypt
{
public partial class EncryptForm : Form
{
public EncryptForm()
{
InitializeComponent();
}
// creates an instance of the web service as a member of the class, will put it down below, doesn't seem to work though declared in the using statement
private nameofURL.EncryptUserLink userform = new nameofUrl.EncryptUserLink();
[System.Web.Services.WebMethod]
private void testButton_Click_1(object sender, EventArgs e)
{
//method to send on button click, then recieve the string to show it works, it should come out as http://CLIENTNAME.info-exchange.com/yyyyMMddHHmmssDomainUsername
//create instances of the details
string[] it;
//send string
//recieve string and display, it must display the same as what was sent.
}
}
}