LoreX75
12-02-2010, 07:01 AM
Hi.
I've just tried to export a class with the WebServiceExporter but, as per standard asmx services, I got an error as the returned type is an interface; is there any work around for this?
I put below an example:
public interface IWsTest
{
string SayHello();
ICiao SayCiao();
}
public class WsTest : IWsTest
{
public string SayHello()
{
return "hello world";
}
public ICiao SayCiao()
{
return new Ciao("Ciao");
}
}
public class Ciao : ICiao
{
private string _saluto;
public Ciao(string saluto)
{
Saluto = saluto;
}
public string Saluto
{
get { return _saluto; }
set { _saluto = value; }
}
}
public interface ICiao
{
string Saluto { set; get; }
}
and the spring config:
<object id="autoProva"
type="MyNamespace.WsTest, MyAssembly">
</object>
<object id="autoProvaExporter"
name="/autosend/WsTest.asmx"
type="Spring.Web.Services.WebServiceExporter, Spring.Web">
<property name="TargetName" value="autoProva"/>
<property name="Name" value="autoProva"/>
<property name="Namespace" value="http://MySite/WebServices"/>
<property name="Description" value="Test"/>
</object>
I get the followind exception:
[NotSupportedException: It's not possible to serialize the interfaceICiao.]
[...]
It's quite unfair to create a webservice interface which is coupled with real classes instead of interfaces, isn't it?
Thanks for any suggestion,
Lorenzo
I've just tried to export a class with the WebServiceExporter but, as per standard asmx services, I got an error as the returned type is an interface; is there any work around for this?
I put below an example:
public interface IWsTest
{
string SayHello();
ICiao SayCiao();
}
public class WsTest : IWsTest
{
public string SayHello()
{
return "hello world";
}
public ICiao SayCiao()
{
return new Ciao("Ciao");
}
}
public class Ciao : ICiao
{
private string _saluto;
public Ciao(string saluto)
{
Saluto = saluto;
}
public string Saluto
{
get { return _saluto; }
set { _saluto = value; }
}
}
public interface ICiao
{
string Saluto { set; get; }
}
and the spring config:
<object id="autoProva"
type="MyNamespace.WsTest, MyAssembly">
</object>
<object id="autoProvaExporter"
name="/autosend/WsTest.asmx"
type="Spring.Web.Services.WebServiceExporter, Spring.Web">
<property name="TargetName" value="autoProva"/>
<property name="Name" value="autoProva"/>
<property name="Namespace" value="http://MySite/WebServices"/>
<property name="Description" value="Test"/>
</object>
I get the followind exception:
[NotSupportedException: It's not possible to serialize the interfaceICiao.]
[...]
It's quite unfair to create a webservice interface which is coupled with real classes instead of interfaces, isn't it?
Thanks for any suggestion,
Lorenzo