The injection of empty in the spring framework is a headache, and it is easier to find the cause of the problem when WebService and the spring framework fit.
In the SSO system encountered this problem, in the service implementation class to inject Ibatis database operations Mapper has been empty, and finally found that the reason is Xfire and spring when used in conjunction with the normal use of Xfire configuration different
Xfire can quickly release webservice, which typically requires only a few steps below.
1. Create service Interfaces and implementation classes
such as Ssomethodsservices and Ssomethodsimpl.
Injection in the implementation class including the Spring annotation form
@Autowired
Private Accountmapper Accountmapper;
2. Add Xfire configuration in Web.xml
<servlet>
<servlet-name>XFireServlet</servlet-name>
<display-name>xfire servlet </display-name>
<servlet-class>
org.codehaus.xfire.transport.http.XFireConfigurableServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> xfireservlet</servlet-name>
<url-pattern>/servlet/XFireServlet/*</url-pattern>
< /servlet-mapping>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
3. Create a directory under the Classpath directory Meta-inf>xifre->services.xml
Configuring services in the Services.xml file
<?xml version= "1.0" encoding= "UTF-8"?>
<beans>
<service xmlns= "http://xfire.codehaus.org/ config/1.0 ">
<name>SSOMethodsServices</name>
<serviceClass> Com.test.sso.ssomethodsservices</serviceclass>
<implementationClass> com.test.sso.impl.ssomethodsimpl</implementationclass>
</service>
</beans>
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/
In this way, you can see the published WebService in the browser input ip:port/projectname/services, and click WSDL to see the WSDL file.
However, the SOAPUI was used to test and found that the injected accountmapper was empty. There is a problem.
Attempts to direct manual injection, add @component annotation and add packet scanning and other methods can not be injected, and later found that its real xfire example directory with spring example, the use of different configuration methods, this way proved to be effective.
The main differences are:
1. Servlet class uses Org.codehaus.xfire.spring.XFireSpringServlet Rather than Org.codehaus.xfire.transport.http.XFireConfigurableServlet. This is the most critical point.
2. Add Xfire-servlet.xml to Web.xml Context-param using a xfire-servlet.xml profile configuration service instead of Services.xml.
3. Add the bean of the WebService implementation class to the Applicationcontext.xml.