gpt4 book ai didi

web-services - 如何使@WebService Spring 感知

转载 作者:行者123 更新时间:2023-12-04 10:21:16 26 4
gpt4 key购买 nike

我有一个 Web 服务,我正在尝试将变量 Autowiring 到其中。这是类(class):

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 服务时,我返回了失败版本,这意味着没有 Autowiring upgradeController。这是我的应用程序上下文:
<?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" class="com.xetius.isales.pr7.logic.UpgradeController" />

</beans>

我如何才能使 @WebService 类具有 Spring 感知能力并发生 Autowiring

最佳答案

如果您希望 Autowiring 发生,ProductRulesWebService 需要扩展 SpringBeanAutowiringSupport

扩展该类将允许 Autowiring UpgradeController

关于web-services - 如何使@WebService Spring 感知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5041154/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com