我正在尝试设置一个Spring.net网络服务,但一直收到一条我无法弄清楚的错误消息。
错误:
System.NotSupportedException: Target 'target' of type 'Spring.Objects.Factory.Support.RootWebObjectDefinition' does not support methods of 'StudentRegistration.Services.IBoundaryService'.
at Spring.Util.AssertUtils.Understands(Object target, String targetName, Type requiredType)
at HelloWorldExporter.GetAllBounds()
代码:
public interface IBoundaryService {
XmlDocument GetAllBounds();
}
public class BoundaryService :IBoundaryService
{
public virtual IBoundaryDao BoundaryDao { get; set; }
public virtual XmlDocument GetAllBounds()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<test>ok</test>");
return xmlDoc;
}
}
配置:
<object name="BoundaryService" type="StudentRegistration.Services.BoundaryService, StudentRegistration"
abstract="true">
</object>
<object id="BoundaryExporter" type="Spring.Web.Services.WebServiceExporter, Spring.Web">
<property name="TargetName" value="BoundaryService"/>
<property name="Namespace" value="http://fake/services"/>
<property name="Description" value="something"/>
<property name="MemberAttributes">
<dictionary>
<entry key="GetAllBounds">
<object type="System.Web.Services.WebMethodAttribute, System.Web.Services">
<property name="Description" value="something."/>
<property name="MessageName" value="GetAllBounds"/>
</object>
</entry>
</dictionary>
</property>
</object>
我该怎么做才能清除它?
答案 0 :(得分:2)
Spring.NET引用在xml声明中是错误的(几天前我有同样的问题),或者我应该说它不是很清楚。
<object name="BoundaryService"
type="StudentRegistration.Services.BoundaryService, StudentRegistration"
abstract="true" />
如果您拥有实际的.asmx
服务
如果您使用Spring.Web.Services.WebServiceExporter
导出为WebService的PONO,则必须将要导出的对象声明为:
<object id="BoundaryService"
type="StudentRegistration.Services.BoundaryService, StudentRegistration"
/>
WebServiceExporter的target
属性适用于声明对象的id
,因为Spring.NET承担生成Web服务的角色,所以不需要抽象部分。
请注意,您公开的服务名称(包含您当前的cfg)将为(..)/BoundaryExporter.asmx
编辑: 使用名称,类型属性的标准.asmx Web服务的配置语句似乎被打破,至少对于Spring版本1.3.0.20349