I wrote a simple JAX-WS web service for tomcat application server on java.
I have one interface and on implementation class:
interface
@WebService(name = "myWs")
@SOAPBinding(style = Style.RPC)
public interface IMyWs {
@WebMethod(operationName = "getUser")
Response getUser(@WebParam(name = "phone", mode = Mode.IN) String phone);
}
implementation
@WebService(endpointInterface = "ge.mari.IMyWs")
public class MyWs implements IMyWs {
@Override
public Response getUser(String phone) {
// SOME CODE
return response;
}
}
My problem is that, in my wsdl file Response class is defined in xsd file.
This is the snippet from my wsdl file
<types>
<xsd:schema>
<xsd:import namespace="http://ws.mari.ge/" schemaLocation="http://localhost:8080/MyServcie/MyWs?xsd=1">
</xsd:import>
</xsd:schema>
</types>
How can I make web service to generate all types in WSDL file instead of separate XSD file?
Should I change any configuration or add some annotation to my web service?
Generating a WSDL From a Web Service Class On the Project Explorer or Navigator tab, right-click the web service class and select Web Services > Generate WSDL.
Create a WSDL descriptor from Java code Select the desired class name in the editor. In the main menu, go to Tools | XML WebServices and WSDL | Generate WSDL From Java Code. In the Generate WSDL From Java dialog that opens, specify the following: The name and URL address of the Web service.
You can have JAX-WS insert the generated schema into your WSDL file by using the
-inlineSchemas
command line switch. [1]
If you're using Maven in your project you can configure the JAX-WS maven plugin to do the same with the inlineSchemas configuration element in your execution configuration as follows: [2]
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>SomeId</id>
<goals>
<goal>wsgen</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<sei>some.class.Name</sei>
<genWsdl>true</genWsdl>
<keep>true</keep>
<resourceDestDir>some/target/dir</resourceDestDir>
<inlineSchemas>true</inlineSchemas>
</configuration>
</execution>
</executions>
</plugin>
No changes to your Java class are necessary.
[1] http://jax-ws.java.net/nonav/2.2.1/docs/wsgen.html
[2] http://jax-ws-commons.java.net/jaxws-maven-plugin/wsgen-mojo.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With