How can I get my Spring.net Webservice working?

老子叫甜甜 提交于 2020-01-06 08:45:31

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/4229800/how-can-i-get-my-spring-net-webservice-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!