I am developed an app in Visual Studio C#. The app is done. Now I want to convert the app to a web service to be called by other apps in our very large network installation. I am at the stage where I am learning to use web service. So far, I have a simple HelloWorldToken type web app in a web service Solution.
public WebService() { }
[WebMethod]
public string HelloWorld()
{
return "Hello World - invoke me";
}
[WebMethod]
public string webServiceAdd(int a, int b)
{
int c = a + b;
return " " + a + " + " + b + " = " + c;
}
[WebMethod]
public string HelloWorldToken(string Token)
{
return "Hello World authToken = " + Token ;
}
This works when I call it from the Visual Studio environment, and also works from an HTML web page. The "action" tag calls the web service, and there are hidden fields in the form that contain the values to be passed.
<form target="_blank"
action=http://localhost:51090/WebService.asmx/webServiceAdd
method="POST">
<tr>
<td>
Invoke Web Service <br />(from form)
<input type="hidden" value="5" name="a" />
<input type="hidden" value="4" name="b" />
<input type="hidden" value="myUserName" name="usr" />
<input type="hidden" value="myPassword" name="psw" />
<input type="hidden" value="theToken" name="Token" />
</td>
<td align="left">
<input type="submit" value="Invoke" class="button">
</td>
</tr>
So far, so good. The web page successfully calls the web service and the web service returns the value generated successfully.
However, ultimately I will need to call the web service from a separate C# application. But to load the separate C# calling code, I must unload the web service code Solution. When I unload the web service, it stops operating. Any calls to it are not found.
I don't have access to an IIS on my computer due to installation rules (very tight). Running Visual Studio 2017 Professional.
My request is to have the web service running on the Visual Studio internal server, while also testing a different Visual Studio C# application (in a different Solution) to call the web service. Is this possible?
Aucun commentaire:
Enregistrer un commentaire