webservice用wsdl2java來生成客戶端(操作簡單方便)


打開Eclipse,Run--> Run Configurations,在Main class框里 輸入 WSDL2Java 進行搜索,前提是你的工程里已加入axis的jar包,
會搜索到org.apache.axis.wsdl.WSDL2Java,在arguments標簽欄里輸入參數,默認基礎目錄為當前工程,參數如下所示:
src\\cfg\\test.wsdl -p com.xxx.xxx.xxx.client -t 
這是wsdl文件在本地的情況,如果不是本地的wsdl文件,那么而是網址方式的(如:http://xxx:8080/xxx/xxx/xxx?wsdl),那么就輸入:
http://xxx:8080/xxx/xxx/xxx?wsdl -p com.xxx.xxx.xxx.client -t
這是比較簡單的生成客戶端代碼參數,運行就可以,刷新工程,會與src同級的地方出現com.test.outsys.prod.client之前設置的包名 ,
復制到src下即可。
其他參數使用方法:
    -h, --help
       print this message and exit
    -v, --verbose
       print informational messages
    -n, --noImports
       only generate code for the immediate WSDL document
    -O, --timeout <argument>
       timeout in seconds (default is 45, specify -1 to disable)
    -D, --Debug
       print debug information
    -W, --noWrapped
       turn off support for "wrapped" document/literal
    -q, --quiet
       do not print any informational or debug messages (except err
       ors)
    -s, --server-side
       emit server-side bindings for web service
    -S, --skeletonDeploy <argument>
       deploy skeleton (true) or implementation (false) in deploy.w
       sdd.  Default is false.  Assumes --server-side.
    -N, --NStoPkg <argument>=<value>
       mapping of namespace to package
    -f, --fileNStoPkg <argument>
       file of NStoPkg mappings (default NStoPkg.properties)
    -p, --package <argument>
       override all namespace to package mappings, use this package
        name instead
    -o, --output <argument>
       output directory for emitted files
    -d, --deployScope <argument>
       add scope to deploy.wsdd: "Application", "Request", "Session
       "
    -t, --testCase
       emit junit testcase class for web service
    -a, --all
       generate code for all elements, even unreferenced ones
    -T, --typeMappingVersion <argument>
       indicate 1.1 or 1.2.  The default is 1.1 (SOAP 1.1 JAX-RPC c
       ompliant.  1.2 indicates SOAP 1.1 encoded.)
    -F, --factory <argument>
       name of a custom class that implements GeneratorFactory inte
       rface (for extending Java generation functions)
    -H, --helperGen
       emits separate Helper classes for meta data
    -B, --buildFile
       emit Ant Buildfile for web service
    -U, --user <argument>
       username to access the WSDL-URI
    -P, --password <argument>
       password to access the WSDL-URI
    -X, --classpath
       additional classpath elements
    -i, --nsInclude <argument>
       include namespace in generated code
    -x, --nsExclude <argument>
       exclude namespace from generated code
    -c, --implementationClassName <argument>
       custom name of web service implementation
    -u, --allowInvalidURL
       emit file even if WSDL endpoint URL is not a valid URL
    -w, --wrapArrays
       Prefers building beans to straight arrays for wrapped XML ar
       ray types (defaults to off).


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM