简体   繁体   中英

How can I get my Spring.net Webservice working?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM