简体   繁体   中英

How do I call a SOAP service in ASP.NET

I'm new to Visual Studio and ASP, I need to call a SOAP service that requires passing in a username and password and responds with a Token. I know how to do this in Javascript, but am clueless in C# / ASP.NET.

I have added the Service reference, and it seems to see that there is an issueToken call. But I can't figure out how to use it and pass in the username and password.

I have tried searching google and on here, but everything I have found is basically "add it as a service reference and use it", but I can't figure out the use it part. All I want is to click a button, send the call, and get a token.

This is what I have... not that it'll help.

protected void Button1_Click(object sender, EventArgs e)
{
    string userName = "Name";
    string password = "Password";
    TokenService.issueToken callToken = new TokenService.issueToken();
}

It'll look something like this:

string userName = "Name";
string password = "Password";
var proxy = new TokenServiceClient();
var token = proxy.issueToken(userName, password);
proxy.Close();

Maybe you need to instantiate the Service before.

TokenService myService = new TokenService();
myService.YourDesiredMethod(userName, password);

Seems like you tried to call a static Method on the Service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM