如何使Spring.net Web服务正常工作? [英] How can I get my Spring.net Webservice working?

查看:71
本文介绍了如何使Spring.net Web服务正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置Spring.net Web服务,但不断收到一条我无法弄清的错误消息.

错误:

  System.NotSupportedException:类型"Spring.Objects.Factory.Support.RootWebObjectDefinition"的目标"target"不支持"StudentRegistration.Services.IBoundaryService"的方法.在Spring.Util.AssertUtils.Understands(对象目标,字符串targetName,类型requiredType)在HelloWorldExporter.GetAllBounds() 

代码:

 公共接口IBoundaryService {XmlDocument GetAllBounds();}公共类BoundaryService:IBoundaryService{公共虚拟IBoundaryDao BoundaryDao {get;放;}公共虚拟XmlDocument GetAllBounds(){XmlDocument xmlDoc =新的XmlDocument();xmlDoc.LoadXml(< test> ok</test>"));返回xmlDoc;}} 

配置:

 <对象名="BoundaryService" type ="StudentRegistration.Services.BoundaryService,StudentRegistration"abstract ="true"></object>< object id ="BoundaryExporter" type ="Spring.Web.Services.WebServiceExporter,Spring.Web"><属性名称="TargetName"值="BoundaryService"/><属性名称=名称空间"值="http://fake/services"/><属性名称=说明" value ="something"/><属性名称="MemberAttributes">< dictionary>< entry key ="GetAllBounds">< object type ="System.Web.Services.WebMethodAttribute,System.Web.Services"><属性名称=说明" value =某物."/><属性名称="MessageName"值="GetAllBounds"/></object></entry></dictionary></property></object> 

我应该如何解决这个问题?

解决方案

Spring.NET参考在xml声明上是错误的(几天前我有同样的问题),或者我应该说它不清楚./p>

 < object name ="BoundaryService"type ="StudentRegistration.Services.BoundaryService,StudentRegistration"abstract ="true"/> 

上面的声明在您具有实际的 .asmx 服务

时适用

如果您有一个PONO,您可以使用 Spring.Web.Services.WebServiceExporter 将其作为WebService导出,则必须将要声明的对象声明为:

 < object id ="BoundaryService"type ="StudentRegistration.Services.BoundaryService,StudentRegistration"/> 

WebServiceExporter的 target 属性适用于已声明对象的 id ,由于Spring.NET负责生成Web服务,因此不需要抽象部分./p>

请注意,您公开的服务名称(使用当前cfg)将为(..)/BoundaryExporter.asmx

使用名称,类型属性的标准.asmx Web服务的配置语句似乎已损坏,至少对于春季版本1.3.0.20349

I am trying to setup a Spring.net web-service but keep getting an error message that I cannot figure out.

Error:

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()

Code:

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;
        }
    }

Configuration:

  <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>

What should I try to clear this up?

解决方案

The Spring.NET reference is wrong on the xml declaration (i had the same issue a few days ago), or should i say its not crystal clear.

<object name="BoundaryService" 
        type="StudentRegistration.Services.BoundaryService, StudentRegistration"
        abstract="true" />

the above declaration applies when you have an actual .asmx service

WHen you have a PONO which you export as a WebService using Spring.Web.Services.WebServiceExporter the object that will be exported must be declared as:

<object id="BoundaryService" 
        type="StudentRegistration.Services.BoundaryService, StudentRegistration"
 />

the target property of the WebServiceExporter applies to the id of a declared object, the abstract part is not required as Spring.NET takes the role generating the webservice.

Note that your exposed service name (with your current cfg) will be (..)/BoundaryExporter.asmx

Edit: The config statement for standard .asmx web services using the name, type attributes seems to be broken, at least for spring version 1.3.0.20349

这篇关于如何使Spring.net Web服务正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆