web-services – 如何让@WebService感知Spring

web-services – 如何让@WebService感知Spring,第1张

概述我有一个Web服务,我试图将变量自动装入.这是班级: package com.xetius.isales.pr7.service;import java.util.Arrays;import java.util.List;import javax.jws.WebService;import org.springframework.beans.factory.annotation.Au 我有一个Web服务,我试图将变量自动装入.这是班级:
package com.xetius.isales.pr7.service;import java.util.Arrays;import java.util.List;import javax.jws.WebService;import org.springframework.beans.factory.annotation.autowired;import com.xetius.isales.pr7.domain.PR7Product;import com.xetius.isales.pr7.domain.PR7Upgrade;import com.xetius.isales.pr7.logic.UpgradeControllerInterface;@WebService(servicename="ProductRulesService",portname="ProductRulesPort",endpointInterface="com.xetius.isales.pr7.service.ProductRulesWebService",targetnamespace="http://pr7.isales.xetius.com")public class ProductRulesWebService implements ProductRulesWebServiceInterface {    @autowired    private UpgradeControllerInterface upgradeController;    @OverrIDe    public List<PR7Product> getProducts() {        if (upgradeController == null) {            return Arrays.asList(new PR7Product("Fail"));        }        return upgradeController.getProducts();    }    @OverrIDe    public List<PR7Upgrade> getUpgrades() {        if (upgradeController == null) {            return Arrays.asList(new PR7Upgrade("Fail"));        }        return upgradeController.getUpgrades();    }    @OverrIDe    public List<PR7Product> getProductsForUpgradeWithname(String upgradename) {        if (upgradeController == null) {            return Arrays.asList(new PR7Product("Fail"));        }        return getProductsForUpgradeWithname(upgradename);    }}

但是,当我尝试访问Web服务时,我收到了Fail版本,这意味着upgradeController没有自动装配.这是我的applicationContext:

<?xml version="1.0" enCoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"    xsi:schemaLocation="http://www.springframework.org/schema/beans                        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd                        http://www.springframework.org/schema/context                        http://www.springframework.org/schema/context/spring-context-3.0.xsd">    <context:component-scan base-package="com.xetius.isales.pr7" />    <context:annotation-config />    <bean ID="upgradeController"  /></beans>

如何使@WebService类具有d簧感知并自动装配发生

解决方法 如果您希望自动装配发生,ProductRulesWebService需要扩展SpringBeanautowiringSupport

扩展该类将允许UpgradeController自动装配

总结

以上是内存溢出为你收集整理的web-services – 如何让@WebService感知Spring全部内容,希望文章能够帮你解决web-services – 如何让@WebService感知Spring所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1136885.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存