Use Java™ API for XML-Based Web Services (JAX-WS) tools to generate the necessary JAX-WS and Java Architecture for XML Binding (JAXB) Java artifacts that are needed for JAX-WS Web services applications when starting from JavaBeans™ or enterprise beans components.
You are not required to develop a WSDL file when developing JAX-WS Web services using the bottom-up approach of starting with JavaBeans. The use of annotations provides all of the WSDL information necessary to configure the service endpoint or the client. The application server supports WSDL 1.1 documents that comply with Web Services-Interoperability (WS-I) Basic Profile 1.1 specifications and are either Document/Literal style documents or RPC/Literal style documents. Additionally, WSDL documents with bindings that declare a USE attribute of value LITERAL are supported while the value, ENCODED, is not supported. For WSDL documents that implement a Document/Literal wrapped pattern, a root element is declared in the XML schema and is used as an operation wrapper for a message flow. Separate wrapper element definitions exist for both the request and the response.
To ensure the wsgen command does not miss inherited methods on a service endpoint implementation bean, you must either add the @WebService annotation to the desired superclass or you can override the inherited method in the implementation class with a call to the superclass method.
Although a WSDL file is typically optional when developing a JAX-WS service implementation bean, it is required if your JAX-WS endpoints are exposed using the SOAP over JMS transport and you are publishing your WSDL file. If you are developing an enterprise JavaBeans service implementation bean that is invoked using the SOAP over JMS transport, and you want to publish the WSDL so that the published WSDL file contains the fully resolved JMS endpoint URL, then have wsgen tool generate the WSDL file by specifying the -wsdl argument. In this scenario, you must package the WSDL file with your Web service application.
You have the required Java artifacts to create a JAX-WS Web service.
Error: Two classes have the same XML type name .... Use @XmlType.name and @XmlType.namespace to assign different names to them...This error indicates that you have classes or @XMLType.name values that have the same name, but exist within different Java packages. To prevent this error, add the @XML.Type.namespace class to the existing @XMLType annotation to differentiate between the XML types.gotcha
With JAX-WS applications, the wsgen command-line
tool might not locate shared class files. You can specify the location
of these class files using the com.ibm.websphere.webservices.wsdl_generation_extra_classpath
custom property. For more information, see the documentation about
the Java virtual machine custom
properties.
/* This is a sample EchoServicePortTypeImpl.java file. */ package com.ibm.was.wssample.echo; @javax.jws.WebService(serviceName = "EchoService", endpointInterface = "com.ibm.was.wssample.echo.EchoServicePortType", targetNamespace="http://com/ibm/was/wssample/echo/", portName="EchoServicePort") public class EchoServicePortTypeImpl implements EchoServicePortType { public EchoServicePortTypeImpl() { } public String invoke(String obj) { System.out.println(">> JAXB Provider Service: Request received.\n"); String str = "Failed"; if (obj != null) { try { str = obj; } catch (Exception e) { e.printStackTrace(); } } return str; } }
/* This is a sample EchoServicePortType.java file. */ package com.ibm.was.wssample.echo; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.WebService; import javax.xml.ws.RequestWrapper; import javax.xml.ws.ResponseWrapper; @WebService(name = "EchoServicePortType", targetNamespace = "http://com/ibm/was/wssample/echo/", wsdlLocation="WEB-INF/wsdl/Echo.wsdl") public interface EchoServicePortType { /** * * @param arg0 * @return * returns java.lang.String */ @WebMethod @WebResult(name = "response", targetNamespace = "http://com/ibm/was/wssample/echo/") @RequestWrapper(localName = "invoke", targetNamespace = "http://com/ibm/was/wssample/echo/", className = "com.ibm.was.wssample.echo.Invoke") @ResponseWrapper(localName = "echoStringResponse", targetNamespace = "http://com/ibm/was/wssample/echo/", className = "com.ibm.was.wssample.echo.EchoStringResponse") public String invoke( @WebParam(name = "arg0", targetNamespace = "http://com/ibm/was/wssample/echo/") String arg0); }
app_server_root\bin\wsgen.bat -wsdl -s c:\generated_source\ -cp c:\my_application\classes\ com.ibm.was.wssample.echo.EchoServicePortTypeImpl -verbose -d c:\generated_artifacts\
app_server_root/bin/wsgen.sh -wsdl -s c:/generated_source/ -cp c:/my_application/classes/ com.ibm.was.wssample.echo.EchoServicePortTypeImpl -verbose -d c:/generated_artifacts/
/generated_source/com/ibm/was/wssample/echo/EchoStringResponse.java /generated_source/com/ibm/was/wssample/echo/Invoke.java /generated_artifacts/EchoService.wsdl /generated_artifacts/EchoService_schema1.xsd /generated_artifacts/com/ibm/was/wssample/echo/EchoStringResponse.class /generated_artifacts/com/ibm/was/wssample/echo/Invoke.class
The EchoStringResponse.java and Invoke.java files are the generated Java class files. The compiled versions of the generated Java files are EchoStringResponse.class and Invoke.class files. The EchoService.wsdl and EchoService_schema1.xsd files are generated because the -wsdl option was specified.
Complete the implementation of your JAX-WS Web service application.
In this information ...Subtopics
Related tasks
Related reference
| IBM Redbooks, demos, education, and more(Index) |