question

MarkusFreitag-0088 avatar image
0 Votes"
MarkusFreitag-0088 asked LimitlessTechnology-2700 answered

How to create a Web Service Project - Server, Client in C# - Some questions

Hello,
I make a WebServer with this instruction.
how-to-create-a-web-service-project-in-net-using-visual-studio


Was ok. It is running
http://localhost:52683/WebService.asmx

To make it work I had to turn on the IIS.
How can I make the server active without VisualStudio?
164733-webservice-running-without-visualstudio.png



After that I created a WSDL file
and creates a proxy class.


C:\Users\freitag\source\repos\WebServiceProject>wsdl /par Test.wsdl
Microsoft (R)-WSDL-Hilfsprogramm (Web Services Description Language)
[Microsoft (R) .NET Framework, Version 4.6.1055.0]
Copyright (C) Microsoft Corporation. All rights reserved.
Datei 'C:\Users\freitag\source\repos\WebServiceProject\WebService.cs' wird geschrieben

C:\Users\freitag\source\repos\WebServiceProject>

Is this way right?


Then a C# client and I can call the functions. The question is how can I start the server without Visual Studio so I can test the client.

Can I also write a function that returns a json object. Do you have an example for this?


 private void Form1_Load(object sender, EventArgs e)
         {
             using (WebService testClient= new WebService())
             {
                 string test1 = testClient.HelloWorld();
    
                 List<int> lstTest = new List<int>();
                 lstTest.Add(7);
                 lstTest.Add(7);
                 lstTest.Add(7);
                 lstTest.Add(7);
                 int result = testClient.Add(lstTest.ToArray());
             }
         }

164727-webservice-1.png

164734-webservice-2-wsdl.png

Could I also implement an ASMX file in the client? Do I necessarily need a WSDL file?

164742-webservice-cs.txt


dotnet-csharpwindows-server-iisdotnet-aspnet-core-generalwindows-server-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SamWu-MSFT avatar image
1 Vote"
SamWu-MSFT answered

@MarkusFreitag-0088

This problem occurs because the website doesn't have the Directory Browsing feature enabled. Also, the default document isn't configured. To resolve this problem, use one of the following methods:

Method 1: Enable the Directory Browsing feature in IIS

  1. Start IIS Manager. To do it, select Start, select Run, type inetmgr.exe, and then select OK.

  2. In IIS Manager, expand server name, expand Web sites, and then select the website that you want to change.

  3. In the Features view, double-click Directory Browsing.

  4. In the Actions pane, select Enable.

Method 2: Add a default document

  1. Start IIS Manager. To do it, select Start, select Run, type inetmgr.exe, and then select OK.

  2. In IIS Manager, expand server name, expand Web sites, and then select the website that you want to change.

  3. In the Features view, double-click Default Document.

  4. In the Actions pane, select Enable.

  5. In the File Name box, type the name of the default document, and then select OK.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AgaveJoe avatar image
1 Vote"
AgaveJoe answered MarkusFreitag-0088 commented

How can I make the server active without VisualStudio?

I assume you want to publish to local IIS and you have installed IIS Manager.

First create a publish profile for your ASMX service.

  • Create a WebService folder in C:\inetpub\wwwroot using Windows Explorer.

  • In visual Studio right click the WebService project and select publish.

  • Select the publish to a local folder option and click next

  • Enter C:\inetpub\wwwroot\webservice (the folder you created above) as the target folder and click next.

  • Click publish.

Open IIS and create a new application.

  • Open IIS Manager (start -> run -> inetmgr)

  • Expand the computer name

  • Expand sites

  • Expand Default Web Site

  • Right click "WebService" (the folder you created above)

  • Select "Convert to Application"

  • Click "Ok"

Open your browser and enter "http://localhost/WebService/WebService.asmx"

You can create a Service Reference from Visual Studio which is more convenient than wsdl.exe. wdsl.exe works fine but it's an older utility.

I think it is important to mention that you tagged this post as ASP.NET Core and this question is ASP.NET not Core. Secondly, ASMX is a very old technology. If you need a JSON response then create a Web API project.

Lastly, creating an IIS application is not required. Visual Studio can run multiple projects. Simply right click on the solution file in Visual Studio solution explorer and select properties. Configure the start up options.

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


I assume you want to publish to local IIS and you have installed IIS Manager.

Right!


Publication error

Publishing error.
The object reference was not set to an object instance.
A diagnostic log was saved to the following location:

I lose the connection...?
http://localhost:52683/ then the error message

I added manual
http://localhost:52683/WebService.asmx , then works, however Any idea


164802-s-1.png
164689-s-1-aaa.png
164782-s30-aa.png


0 Votes 0 ·
s-1.png (32.2 KiB)
s-1-aaa.png (34.4 KiB)
s30-aa.png (38.4 KiB)

164814-error1.png

13.01.2022 14:10:51
System.AggregateException: Mindestens ein Fehler ist aufgetreten. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Fehler beim Erstellen. Weitere Details finden Sie im Ausgabefenster.
--- Ende der internen Ausnahmestapelüberwachung ---
---> (Interne Ausnahme #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Fehler beim Erstellen. Weitere Details finden Sie im Ausgabefenster.<---

Microsoft.WebTools.Shared.Exceptions.WebToolsException: Fehler beim Erstellen. Weitere Details finden Sie im Ausgabefenster.

===================

Not so easy. Any idea?


Why that error?

164735-error1-b.png


Must I set here something?

164709-here.png

Is empty, why?
164767-is-empty.png


0 Votes 0 ·
error1.png (33.2 KiB)
error1-b.png (43.6 KiB)
here.png (40.9 KiB)
is-empty.png (13.7 KiB)
SamWu-MSFT avatar image SamWu-MSFT MarkusFreitag-0088 ·

@MarkusFreitag-0088 The information on the 403.14 error page you posted doesn't seem to be in English, can you convert it to English? or you can also use failed request tracking to view detailed error information.

1 Vote 1 ·

The information on the 403.14 error page you posted doesn't seem to be in English, can you convert it to English?

Sure.
The web server is configured not to list the contents of this directory.

search

Thanks for your help in advance.


If that worked it would be a great help to me. Maybe you can create an example? Have a nice weekend....

0 Votes 0 ·
LimitlessTechnology-2700 avatar image
1 Vote"
LimitlessTechnology-2700 answered

Hi there,

You can host the web application on your local machine, you will need to set up IIS and configure it to do so. Then you would publish the web application to IIS.

By default, IIS 7.5 is not installed on Windows Server. You can install IIS 7.5 IIS by using the Add Roles Wizard in Server Manager or by using the command line.

Installing IIS 7.5 on Windows Server 2008 R2
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-r2-and-2008/cc771209(v=ws.11)




--If the reply is helpful, please Upvote and Accept it as an answer--

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.