First develop your EJB3 session bean web service as follows:
@WebService(name="PlaceBid",
serviceName="PlaceBidService", portName = "PlaceBidPort",
targetNamespace = "http://actionbazaar.com/xml")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
@PersistenceContext(unitName="actionBazaar",name="actionBazaar")
@Stateless
public class PlaceBidBean {
public Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
….
}
}
Deployment
Unlike OC4J, WebLogic do not support parsing of JAX-WS annotations at deployment time and if you try to deploy the compiled EJB 3 Web service, you will get deployment time exception. You have to run the EJB 3 WS thru annotation parsing tool (jwsc –java web services compile) supplied with WebLogic to generate the artifacts and package in your ejb-jar module.
Here is an example ant task to create the web service:
<target
name="build-ws-server" description="Target that builds the
target Web Service">
<jwsc
srcdir="${src.ejb.dir}"
destdir="${bld.service.dir}"
classpath="${common.j2ee.class.path}"
fork="true"
keepGenerated="true"
deprecation="${deprecation}"
keepTempFiles="true"
listfiles="true"
debug="${debug}">
<jws
file="actionbazaar/buslogic/PlaceBidBean.java" type="JAXWS"
explode="true"/>
</jwsc>
</target>
<target name="package-ejb"
depends="compile-ejb-classes,build-ws-server">;
<mkdir dir="${bld.ejb.dir}/actionbazaar/buslogic/jaxws" />
<copy todir="${bld.ejb.dir}/actionbazaar/buslogic/jaxws">
<fileset dir="${bld.service.dir}/actionbazaar/buslogic/PlaceBidBean/actionbazaar/buslogic/jaxws" includes="*"/> </copy>
<echo message="-----> Create EJB jar file"/>
<jar jarfile="${bld.ear.dir}/${ejb.name}.jar">
<fileset dir="${bld.ejb.dir}" includes="**" />
</jar>
</target >
Make sure to package the generated artifacts in the EJB JAR and then deploy the EJB-JAR or EAR to the WebLogic Server. Note that if your web service depends upon custom Java objects - the generated artifacts contain duplicate Java classes that you already may have. These duplicated classes are on a separate package structure and cause ClassCastException for me. So I avoid packaging these classes.
Accessing EJB 3 Web service
After successful deployment you can access the web service as follows:
http://hostname:port/ejb-name/web-service-name?wsdl
http://localhost:7001/PlaceBidBean/PlaceBidBeanService?wsdl
Hope this helps.
You can download the working examples from here. Chapter 15 contains web services example.