在 xml 中注入属性失败(spring-ws 配置)

2023-12-05

我正在使用 Spring-WS 并具有以下 spring-ws-servlet.xml 文件。 defaultURI 和编组器的注入不起作用,因为当我到达服务客户端中的方法时,这些属性为空。 所发生的情况是,使用正确的值调用 setter,但在客户端 getSum() 方法中,这些值为 null。可能出什么问题了?

<?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"
   xmlns:sws="http://www.springframework.org/schema/web-services"
   xmlns:oxm="http://www.springframework.org/schema/oxm"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">

<context:component-scan base-package="com.coral.project.endpoints"/>

<sws:annotation-driven />

<sws:dynamic-wsdl id="test" portTypeName="TestCase" locationUri="/testService/"
                  targetNamespace="http://www.example.org/schemasDef/test/definitions">
    <sws:xsd location="/WEB-INF/schemasDef/test.xsd"/>
</sws:dynamic-wsdl>

<bean id="springWSClient" class="com.coral.project.endpoints.SpringWSClient">
    <property name="defaultUri" value="http://localhost:8080/parking/springServices/testService"/>
    <property name="marshaller" ref="marshaller" />
    <property name="unmarshaller" ref="marshaller" />
</bean>

<oxm:jaxb2-marshaller id="marshaller">
    <oxm:class-to-be-bound name="com.coral.project.entity.Street"/>
</oxm:jaxb2-marshaller>
</beans>

我得到例外:

在组件上调用encodeEnd时出现异常:{Component-Path:[类:org.ajax4jsf.component.AjaxViewRoot,ViewId:/appealConversionStatusReport.jsp] [类:org.apache.myfaces.custom.div.Div,Id:j_id_jsp_1406177460_4][类:com.exadel.htmLib.components.UITable,Id:j_id_jsp_1406177460_5] [类:com.exadel.htmLib.components.UITbody,Id:j_id_jsp_1406177460_6] [类:org.apache.myfaces.component.html.ext.HtmlInputHidden, ID:j_id_jsp_546672833_0]}

造成原因: java.lang.IllegalStateException - 未注册编组器。检查WebServiceTemplate的配置。

客户端:

package com.coral.project.endpoints;

import java.io.IOException;
import java.io.StringWriter;

import javax.inject.Inject;
import javax.xml.soap.SOAPException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamResult;

import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.xml.transform.StringSource;

import com.coral.project.dao.ifc.StreetDao;
import com.coral.project.entity.Street;
import com.coral.utils.SpringUtils;

public class SpringWSClient extends WebServiceGatewaySupport {

public void getSum() throws SOAPException, IOException, TransformerException {
    StreetDao streetDao = SpringUtils.getBean(StreetDao.class);
    Street street = streetDao.findById(1);

    getWebServiceTemplate().marshalSendAndReceive(
    "http://localhost:8080/parking/springServices/testService",street);

}
}

Are you new'ingSpringWSClient你的代码中的实例?

另外,对于 streetDao,您不需要使用SpringUtils.getBean。相反,它应该是一个带有注释的字段@Autowired (or @Resource).

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 xml 中注入属性失败(spring-ws 配置) 的相关文章

随机推荐

  • 如何检测程序何时空闲?

    例如 程序如何检测用户已经有 5 分钟没有使用它了 在 WinForms 中有一个 Application Idle 事件 http msdn microsoft com en us library system windows forms
  • 使用es6从两个对象中获取差异对象

    我试图找出使用 es6 获取两个对象之间的交集对象的最佳方法是什么 我的意思是 a a a b b c c d d b a a b 1 c c d 2 f result I want c getDifference a b c is now
  • 在 javascript 中访问 C# 变量

    我打算用 C NET 设计一个 DMS 教育领域 网站 这是我的新手 在我的一个 ASPX 页面中 我想禁用 JavaScript 中的菜单 根据accessright The accessright存储在数据库表中login作为 SQL
  • 返回一个包含 CompletableFuture 列表的 CompletableFuture

    我正在尝试加快对多个 API 的调用 在下面的代码中 getFilteredEvents是当前同步版本 我有这样的感觉map x gt x getFilteredEvents eventResearch 操作将等待每个 API 的响应 它使
  • 无法将参数从 int * 转换为 const int *&

    我确实明白 const T 是对 const 类型 T 的指针的引用 该指针具有低级 const 因此它不会更改它指向的值 但是 以下代码在编译时失败并给出以下消息 error C2664 void pointer swap const i
  • 如果我在 main() 函数之后放置一个类,C++ 需要编写什么代码

    我正在观看一些有关 C 的视频教程 我知道您必须在使用或调用函数 类之前定义它 但我喜欢将 main 函数放在顶部 而将其他所有内容放在 main 函数下方 我知道如果我在主函数下面定义一个函数 我必须在使用它之前声明它 但是类呢 我需要在
  • C++ 判断类是否可以使用对象 - 文本RPG游戏

    我面临以下设计问题 TL TD 需要确定英雄 类 是否可以使用特定对象 而有很多英雄实现 我有 Hero 类的 3 个子类 每个子类都可以使用特定的物品 对于 Weapons hpp 我有剑 锤子 十字弓 弓 魔杖 法杖 战士可以使用剑或锤
  • 如何防止用户使用后退按钮成功登录后返回登录页面

    我正在开发 MVC3 应用程序 但遇到了登录安全问题 场景是当用户使用他 她的用户名和密码登录时 如果正确 他 她将被重定向到他们的主页 但是 如果他们单击浏览器后退按钮 他们就会返回到登录页面 就我而言 这是我不想要的 就像 facebo
  • 使用 netbeans 调试 cakephp - 无变量

    我按照这些说明使用 netbeans 和 xdebug 设置 cakephp 调试http www tiplite com cakephp debug in netbeans 我让它工作了 但是当我到达断点时我看不到任何变量 有一个选项可以
  • 如何在 OpenCV 中估计两个相机的位置?

    我有来自两个图像的两组对应点 我估计了编码摄像机之间转换的基本矩阵 E mask cv2 findEssentialMat points1 points2 1 0 然后我提取了旋转和平移分量 points R t mask cv2 reco
  • 如何更改 javascript 变量的字体?

    我正在尝试制作一个类似于 cookie clicker 的游戏 这是我的代码的一部分 var clicks 0 function updateClickCount document getElementById clickCount inn
  • .NET 4 出现“找不到指定的过程”错误

    我正在使用 Visual Studio 2012 11 0 51106 01 Update 1 在 64 位 Windows 7 机器上进行开发 我有一个支持项目 它将一些 C 代码编译成 32 位 DLL 在我的标题中我有 define
  • 如何在 Ubuntu 中增加 docker 磁盘映像大小

    我正在尝试增加 ubuntu 上的 docker 映像大小 当我执行 docker info 时 我得到以下信息 Containers 0 Running 0 Paused 0 Stopped 0 Images 0 Server Versi
  • C 从指向结构体第二个成员的指针获取指向结构体的指针是否合法?

    我想知道前面的行是否有注释 这是合法的C吗 在函数中dumpverts 底部 是否合法 C include
  • 如何让rxjs大理石同步分组只占用一帧

    根据https github com ReactiveX rxjs blob master docs app content guide testing marble testing md marble syntax abc on fram
  • 在 Spring AOP 中使用 @AfterReturning 修改类的值

    如何使用 AfterReturning建议修改值 它适用于除字符串之外的任何对象 我知道字符串是不可变的 以及如何在不更改 AccountDAO 类中 saveEverything 函数的返回类型的情况下修改字符串 这是代码片段 Compo
  • 如何比较两个函数的外延等价性,如 (λx.2*x) == (λx.x+x)?

    有没有办法比较两个函数是否相等 例如 x 2 x x x x 应该返回 true 因为它们显然是等价的 众所周知 一般函数相等性通常是不可判定的 因此您必须选择您感兴趣的问题的子集 您可以考虑其中一些部分解决方案 普雷斯堡算术是一阶逻辑 算
  • iPhone的NSUserdefaults是数据库或plist

    我无法正确获取 NSUserDefaults 概念 那是plist文件的数据库吗 它是在应用程序重新启动之间保留的键值存储 它的实现方式与您如何使用它几乎没有关系
  • 递归爬楼梯难题的 Java 基准

    这个现在非常常见的算法问题是监考人员在白板考试期间提出的 我的工作是观察 倾听并客观地判断给出的答案 但我既无法控制所提出的问题 也无法与回答者互动 有五分钟的时间来分析问题 候选人可以编写项目符号 伪代码 在实际代码编写过程中是允许的 只
  • 在 xml 中注入属性失败(spring-ws 配置)

    我正在使用 Spring WS 并具有以下 spring ws servlet xml 文件 defaultURI 和编组器的注入不起作用 因为当我到达服务客户端中的方法时 这些属性为空 所发生的情况是 使用正确的值调用 setter 但在