Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在xml中注入属性失败(spring ws-config)_Spring_Spring Ws - Fatal编程技术网

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

在xml中注入属性失败(spring ws-config),spring,spring-ws,Spring,Spring Ws,我使用的是SpringWS,并具有以下Spring-WS-servlet.xml文件。 defaultURI和marshaller的注入不起作用,因为当我在服务的客户机中访问该方法时,这些属性为null。 发生的情况是,使用正确的值调用setter,但在客户机getSum()的方法中,这些值为null。有什么不对劲吗 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframewor

我使用的是SpringWS,并具有以下Spring-WS-servlet.xml文件。 defaultURI和marshaller的注入不起作用,因为当我在服务的客户机中访问该方法时,这些属性为null。 发生的情况是,使用正确的值调用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>

您是否在代码中使用
SpringWSClient
实例


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

愚蠢的错误!!!正在生成新的SpringWSClient()而不是注入它。
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);

}
}