xsharp.eu • WCF generation incorrect
Page 1 of 1

WCF generation incorrect

Posted: Thu Jun 13, 2019 8:29 pm
by Jamal
It seems the WCF generation code is incomplete. It is creating X# code in Service.prg and C# code in IService1.prg which leads to compile errors.

To replicate, Add WCF to project.

Service1.prg:

Code: Select all

using System
using System.Collections.Generic
using System.Runtime.Serialization
using System.ServiceModel
using System.Text

BEGIN NAMESPACE  xSharpWinFormsApp1

	CLASS Service1 IMPLEMENTS $contractName$
		METHOD DoWork() as VOID STRICT
			RETURN

	END CLASS
END NAMESPACE
IService.prg has C# code:

Code: Select all

using System
using System.Collections.Generic
using System.Runtime.Serialization
using System.ServiceModel
using System.Text

namespace xSharpWinFormsApp1
{
	[ServiceContract]
	public interface IService1
	{
		[OperationContract]
		void DoWork()
	}
}


Also to be able to call a WCF web service from a web application, a X# web application template must be available and which creates a Global.asx.prg to properly setup CORS properties.

Jamal

WCF generation incorrect

Posted: Thu Jun 13, 2019 9:09 pm
by NickFriend
Hi Jamal,

I think that in reality none of the templates or service references as provided in C# are really necessary. We've been working for years without this, simply coding the WCF channels directly in the client app (it's a few dozen lines of pretty generic code).

At the service end it's as you say, simply a matter of decorating the service methods with ServiceContract and OperationContract. That and a one line svc file and some declarations in web.config, then host in IIS.

I can share any (C#) code if it would be of help.

Nick

WCF generation incorrect

Posted: Thu Jun 13, 2019 9:16 pm
by Jamal
Hi Nick,

I have no issues doing this in C# as I've been for years publishing or consuming web services in various flavors.
The point here is X# WCF generation is incorrect; just helping in any way to report such issues to the dev team.

Jamal

WCF generation incorrect

Posted: Thu Jun 13, 2019 10:13 pm
by Chris
Hi Jamal,
Jamal wrote:It seems the WCF generation code is incomplete. It is creating X# code in Service.prg and C# code in IService1.prg which leads to compile errors.
Oops! :)
Confirmed of course, thanks!

WCF generation incorrect

Posted: Fri Jun 14, 2019 2:31 pm
by NickFriend
Ah ok... just thought it was giving you problems as well.

Nick

WCF generation incorrect

Posted: Sat Jun 15, 2019 1:41 pm
by ic2
Hello Jamal,

A few years ago I created the code for X# mainly from Nick's Devshare C# notes; I had to solve quite a couple of problems with code where I hardly understand what it is supposed to do. The most difficult one was actually solved by Nick who checked what happened on the website where I wanted to exchange code with and I ended up with a reliable WCF interface with an X# client and a C# DLL on the website as server.

I am unaware of X# WCF code generation but if you need working code I can send you that.

Dick