How to: Create a WDSL web service with Oxygene

This Howto uses Visual Studio 2017 and Server 2016 Internet Information Services for the examples.

With Oxygene it is very easy to create a WDSL web service.

Step 1: Open the Create New Project wizzard (Ctrl-N)
Select Installed - RemObjects Oxygene - .Net - Web, ASP.Net Web service application

Give the web service a name and select the location where you want the code to be stored, and press the "OK" button to create the project.

This creates the new project:
and opens the generated Service1.asmx.pas file:
Note that this is already is fully functional web service with one published method: HelloWorld.

Step 2: Create your own namespace for the service
The namespace of the service is default: - not that this name has nothing to do with an internet URL - it just defines a unique identifier for the service.

Step 3: Write your code
You can now implement your web service:
- Any method that is prefixed with the [WebMethod()] attribute will be published within your service.
- Any type you define that is used in the parameters or return value of one of the defined webmethods are published by your web service also.

Step 4: Debug your code
In the solution explorer, select the asmx file you want to debug,, and right-click on it and select "Set as Start page". Next, start the project (green start button). The Webservice is started in the IIS-express of Visual Studio, just like an instance of your default browser that opens on your webservice:
Go back to your code, and set a break point on the following line:

Go back to your browser and press the HelloWorld link, and on the page that shows, press Invoke.
The visual studio editor comes to the foreground where the break point is activated - you can now debug your code from here.
After the call completes, the browser opens a new window where the result of the call is displayed:

Step 5: Create the website on your Internet Information Server
Optional - you can use an existing website on your server too.
Open IIS, right-click on the server node and select "New Website".
The following dialog is displayed:

Fill in the site name, select ( or create a new) application pool (The type needs to be .Net 4 integrated), select the physical path for the site and give the username and password that can access this path using the button "Connect as". Optionally you can set the binding information.

Step 6: Compile your code and publish it
Select the project in the solution explorer, right-click on it en select Publish:

The publish wizard will now show:
Select Custom, enter a profile name and press <Enter>.
In the next dialog, choose your way of publishing and supply the needed information.

important: make sure that you use the following configuration settings:
Precompile on, Not updatable.
Otherwise you will get the error'Oxygene' is not a supported language.

If you don't want to distribute a precompiled web service, you have to distribute some extra dll's with your web service, see Deploying ASP.NET Websites

Then press Publish, and your web service is operational.

No comments:

Post a Comment