Java and WCF Interaction (1) Supplement: Generate WSDL Java Client Code with WSImport
In "Java and WCF Interaction (1): Java Client Calls WCF Services", I described the use of an Eclipse control of axis2 to generate WCF. Java client proxy class. Later, a friend suggested to use Xfire and CXF, but I haven't tried it. Today, a friend pointed out that JDK6 can use a WSImport tool that comes with java. I tried it, and it was really cool. This is an exe file. Under JAVA_HOME%\bin, its official instructions, see: http://download-llnw.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html, main parameters:
Option
Description
-d < directory>
Specify where to place generated output files
-b <path>
Specify external JAX-WS or JAXB binding files (Each <file> must have its own -b)
-B <jaxbOption>
Pass this option to JAXB schema compiler
-catalog
Specify catalog file to resolve external entity references, it supports TR9401, XCatalog, and OASIS XML Catalog format. Please read the documentation of catalog and see catalog sample.
-extension
Allow vendor extensions (functionality not specified by the specification). Use of extensions may result in applications that are not portable or may not interoperate with other implementations
-help
Display help
-httpproxy:<host>:<port>
Specify an HTTP proxy server (port defaults to 8080)
-keep
Keep generated files
-p
Specifying a target package via this command-line option, overrides any wsdl and schema binding customization for package name and the default package name algorithm defined in the specification
-s <directory>
Specify where to place generated source files
-verbose
Output messages about what the compiler is doing
-version
Print version information
-wsdllocation <location>
@WebServiceClient.wsdlLocation value
-target
Generate code as per the given JAX-WS specification version. version 2.0 will generate compliant code for JAX-WS 2.0 spec.
-quiet
Suppress wsimport output
示例:wsimport -s JavaSrc http://stockquote.xyz/quote?wsdl
The relevant Java classes will be generated under the JavaSrc of the current path, and copied directly to the Src directory of the project to use.
The following is still the class of http://localhost:8000/HelloTimeService?wsdl created last time. The test process is as follows:
Yaoyue Studio
Yaoyue Studio
Create a new java Project, as shown in the figure:
Yaoyue Studio
Put the java file generated above Copy it to the Src directory, the project structure is shown in the figure:
Yaoyue Studio The
test code is also very simple:
Yaoyue Studio
Summary : This method is very similar to the Stub method generated by Axis2, except that no test code is generated. The structure is fairly clear.
Reprinted from Blog Garden: http://www.cnblogs.com/downmoon/archive/2010/08/29/1811689.html
[Reprint] WSImport generates WSDL Java client code
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326931239&siteId=291194637
Recommended
Ranking