First, set up a good SSH framework:
1. Struts:myeclipse menu bar myeclipse--"Project capabilities--" ADD struts capabilities, select version Struts 1.3,applicationresources Remove the path section, it is best to also remove the following install Struts TLDs check box, complete.
Web-inf\web.xml configuration file (<servlet> to be behind <listener>)
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
2, Hibernate: first with the database link, and then the menu bar myeclipse--"Project capablilities--" ADD hibernate capabilities, select version Hibernate 3.1, in the library choose Hibernate 3.2 Core Libraries, the last Create sessionfactory class option is removed, because it is to be managed with spring.
Applicationcontext.xml configuration file
<!--factory objects--
<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name= "configlocation" value= "Classpath:hibernate.cfg.xml" >
</property>
</bean>
3. Spging: Menu bar myeclipse--"Project capablilities--" ADD spging capabilities, version Select Spring 2, Library core Library Spring 2.5 core Libraries,ok
Web-inf\web.xml configuration file
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Second, then add the Xfire part:
1. Add Xfire Library Package: In the project directory, open the. classpath file, add a line <classpathentrykind= "con" path= " Melibrary.com.genuitec.eclipse.ws.xfire.MYECLIPSE_XFIRE_CORE "/> Save and then refresh in MyEclipse to see the load coming in Xfire library package.
2. Add the necessary jar packages to Webroot\web-inf\lib below: Database packages such as Classes12-9i.zip, Msbase.jar, Mssqlserver.jar, msutil.jar,spring Web Packages (If you choose Spring Web Packages When you take the spring framework) such as Spring-web.jar, Spring-webmvc.jar.
3. Modify the Web-inf\web.xml configuration file and add <servlet> after <listener>
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
There is also a mapping configuration
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Where the <url-pattern>/services/*</url-pattern> represents the WebService class to be placed under the Services directory, Or that everything under the services directory will be treated as a webservice, so pay attention to what's under struts. If you need to put the WebService class under multiple directories to manage, you can continue to add the mapping configuration, as
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/service/servlet/*</url-pattern>
</servlet-mapping>
4, in the Services directory to add an interface class Testservicedao,
@WebService
publicinterfacetestservicedao{
The SayHello method declares the interface that the Web service exposes externally
//@return
public string SayHello (string s);
Note: The above "@WebService" annotation identification is to give the Applicationcontext.xml configuration file using the Jsr181 method, if not Jsr181, can be removed.
5, in the Services directory to add an interface implementation class Testservicedaoimpl,
@WebService (servicename= "TestWebService", endpointinterface= "services. Testservicedao ")
Publicclasstestservicedaoimpl Implementstestservicedao {
public string SayHello (string ss) {
TODO Auto-generatedmethod stub
String Str= "You enter the strings are:" +SS;
System.out.println (str);
return str;
}
Note: The above annotations are intended for use with the Jsr181 method in the Applicationcontext.xml configuration file, @WebService (servicename= "TestWebService", endpointinterface= "Services. Testservicedao "), where ServiceName represents WebService's registered name, is the name that is exposed to the third party, and if it is empty, the default is the name of the interface class, Endpointinterface represents the full name of the interface class to be implemented by the WebService. If you do not use the Jsr181 method configuration, you can remove.
6, configuration applicationcontext.xml in the <bean>, there are two ways:
The first method, using the Jsr181 method, requires that both the interface and the implementation class must have a @webservice annotation identifier, and this method seems to take longer to load when starting Tomcat:
<!--Xfire and spring Integration--
<import resource= "Classpath:org/codehaus/xfire/spring/xfire.xml"/>
<!--get JSR181 annotation of all beans in ApplicationContext
<bean id= "Webannotations"
class= "Org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"/>
<bean id= "Jsr181handlermapping"
class= "Org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping" >
<property name= "Xfire" ref= "Xfire"/>
<property name= "webannotations" ref= "Webannotations"/>
</bean>
The above is fixed, and the following are the additions to each WebService implementation class:
<!--The bean to be published as a Web service--
<bean id= "test1" class= "services. Testservicedaoimpl "/>
The second method, the common method:
<!--Xfire and spring Integration--
<import resource= "Classpath:org/codehaus/xfire/spring/xfire.xml"/>
The above is fixed, and the following are the additions to each WebService implementation class:
<!--The bean to be published as a Web service--
<bean id= "AAA" class= "services. Testservicedao "/>
<bean name= "BBB" class= "Org.codehaus.xfire.spring.ServiceBean" >
<property name= "Servicebean" ref= "AAA"/>
<property name= "ServiceClass" value= "services. Testservicedaoimpl "/>
</bean>
This method publishes the WebService, whose outward-exposed name is the name of the interface class Testservicedao, not the Bean's ID number.
Complete, if you want to know which WebService interface can be called, after starting Tomcat, enter the HTTP://LOCALHOST:8080/project name in the IE Address bar/services can see
Excerpt from huangjl2000w's column
SSH and WebService integration record