我正在寻找各地试图找出如何将无状态会话bean转换为JAX-WS Web服务(我使用的是WAS 7,Websphere Integration Developer,EJB 3)。不是Jax-RPC。我正式厌倦了与WID附带的向导搞乱。出于某种原因,它根本不会让我这样做...我尝试从Java bean创建一个JAX-WS Web服务,换句话说,我创建了一个Java类并在那个东西上运行向导,它创建了一个全新的项目......
是否有某个教程可以在不必使用向导的情况下向我提供创建此Webservice所需的知识?
答案 0 :(得分:5)
从Java EE 5教程中试试A Web Service Example: helloservice - The Java EE 5 Tutorial。
其他:
我写了一个小样本应用程序。
`-- HelloEAR
| |-- .project
| `-- .settings
| |-- org.eclipse.wst.common.component
| |-- org.eclipse.wst.common.project.facet.core.xml
`-- HelloEJB
| `-- .apt_generated
| | `-- org
| | `-- paulvargas
| | `-- ejb
| | `-- jaxws
| | |-- SayHello.java
| | |-- SayHelloResponse.java
| |-- .classpath
| |-- .factorypath
| |-- .project
| `-- .settings
| | |-- org.eclipse.jdt.apt.core.prefs
| | |-- org.eclipse.jdt.core.prefs
| | |-- org.eclipse.wst.common.component
| | |-- org.eclipse.wst.common.project.facet.core.xml
| `-- ejbModule
| | `-- META-INF
| | | |-- ibm-webservices-bnd.xmi
| | `-- org
| | | `-- paulvargas
| | | `-- ejb
| | | |-- HelloBean.class
| | | |-- HelloBean.java
| | | |-- HelloLocal.class
| | | |-- HelloLocal.java
| | | |-- HelloRemote.class
| | | |-- HelloRemote.java
| | | `-- jaxws
| | | |-- SayHello.class
| | | |-- SayHelloResponse.class
`-- HelloWeb
| `-- .apt_generated
| |-- .classpath
| |-- .factorypath
| |-- .project
| `-- .settings
| | |-- .jsdtscope
| | |-- org.eclipse.jdt.apt.core.prefs
| | |-- org.eclipse.jdt.core.prefs
| | |-- org.eclipse.wst.common.component
| | |-- org.eclipse.wst.common.project.facet.core.xml
| | |-- org.eclipse.wst.jsdt.ui.superType.container
| | |-- org.eclipse.wst.jsdt.ui.superType.name
| `-- src
| `-- WebContent
| | `-- WEB-INF
| | `-- classes
| | `-- lib
| | |-- web.xml
package org.paulvargas.ejb;
import javax.ejb.Stateless;
import javax.jws.WebService;
@Stateless
@WebService
public class HelloBean implements HelloRemote, HelloLocal {
public String sayHello(String name) {
return "Hello, " + name + ".";
}
}
package org.paulvargas.ejb;
import javax.ejb.Remote;
@Remote
public interface HelloRemote {
String sayHello(String name);
}
package org.paulvargas.ejb;
import javax.ejb.Local;
@Local
public interface HelloLocal {
String sayHello(String name);
}
<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.etools.webservice.wsbnd:WSBinding
xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:com.ibm.etools.webservice.wsbnd="http://www.ibm.com/websphere/appserver/schemas/5.0.2/wsbnd.xmi">
<routerModules transport="http" name="HelloWeb.war" />
</com.ibm.etools.webservice.wsbnd:WSBinding>
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>HelloWeb</display-name>
<servlet>
<servlet-name>org.paulvargas.ejb.HelloBean</servlet-name>
<servlet-class>com.ibm.ws.websvcs.transport.http.WASAxis2Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>org.paulvargas.ejb.HelloBean</servlet-name>
<url-pattern>/HelloBeanService</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
IDE自动生成文件SayHello.java
和SayHelloResponse.java
。
您可以在http://localhost:9080/HelloWeb/HelloBeanService/HelloBeanService.wsdl