Write a web service

This forum is meant for examples of X# code.

User avatar
softdevo@tiscali.it
Posts: 189
Joined: Wed Sep 30, 2015 1:30 pm

Write a web service

Post by softdevo@tiscali.it »

The reason is that I have to run complex code of my application and then return the result as an xml file.
So to summarize, if I understand correctly, the call to the web service takes place through the public method contained in the CLASS MathServices, which can return values of any type; and to return a file? it's possible? I imagine so.

thank you to all.

Danilo
User avatar
wriedmann
Posts: 3655
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Write a web service

Post by wriedmann »

Hi Danilo,

it is also possible to write an X# service and respond directly to the requests.

You can find a sample here:
https://www.riedmann.it/download/Vulcan ... ener.viaef

I'm using an application based on this sample for several years now on a customers server. The beauty of this solution is that you don't need anything special, as it does not needs any webserver, but uses http.sys that is part of every Windows installation.
The bad notice is that you have to do all by yourself - every input and output processing. This may be to much for a complex website, but is ok for a webservice, where the frontend could be built by a normal webserver.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Write a web service

Post by lumberjack »

softdevo@tiscali.it wrote:The reason is that I have to run complex code of my application and then return the result as an xml file.
So to summarize, if I understand correctly, the call to the web service takes place through the public method contained in the CLASS MathServices, which can return values of any type; and to return a file? it's possible? I imagine so.
thank you to all.
Danilo, am I correct in assuming you have a desktop client that you want to interface to a webservice?
In that case google WSDL, you will find how to create a "local" client for the webservice that you link into your application which will have all the interfaces to communicate with the webservice, no worry about having to convert to xml etc.

Attached a class that I wrote in the Vulcan days to create a c# assembly that you can then use to communicate with the webservice.

Hope this helps.
jhnWSDL.zip
(2.2 KiB) Downloaded 83 times
______________________
Johan Nel
Boshof, South Africa
User avatar
softdevo@tiscali.it
Posts: 189
Joined: Wed Sep 30, 2015 1:30 pm

Write a web service

Post by softdevo@tiscali.it »

Thank you Wolfgang, Precious as usual

Danilo
User avatar
softdevo@tiscali.it
Posts: 189
Joined: Wed Sep 30, 2015 1:30 pm

Write a web service

Post by softdevo@tiscali.it »

I have to provide information processed by my web application, written in XSharp, to an app that will run on an Android or Apple smartphone

Danilo
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

Write a web service

Post by lumberjack »

softdevo@tiscali.it wrote:I have to provide information processed by my web application, written in XSharp, to an app that will run on an Android or Apple smartphone
The only thing you have to do is to [WebMethod] what you want exposed with a return type, the web server (IIS, Apache) will handle the rest of converting to xml and pass to the client.
______________________
Johan Nel
Boshof, South Africa
Jamal
Posts: 315
Joined: Mon Jul 03, 2017 7:02 pm

Write a web service

Post by Jamal »

Hi Johan,

To be able the access the web service, CORS has to be setup properly in the Global.asax file and the a Public Interface has to be created as [ServiceContract] and each method has to be declared, but then I found WCF generation in X# is not correct (it's generating X# and C# code!!). Please see my other post (WCF generation incorrect). Also, It seems now there is no X# template to create a web application, so WCF in X# right may not be ready. I did not see it in the 2019 Road Map.

Jamal
Post Reply