Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 8 for Windows
E50624-01
  Go To Table Of Contents
Contents

Previous
Previous
 
Next
Next
 

19 JSR 172: Web Services Support

The Oracle Java ME SDK 8 emulator supports JSR 172: J2ME Web Services Specification. JSR 172 provides APIs for accessing web services from mobile applications. It also includes an API for parsing XML documents.

NetBeans IDE 8.0 provides a stub generator that automates creating source code for accessing web services that conform to the J2ME Web Services Specification.

Generating Stub Files from WSDL Descriptors

You can add stub files to any MEEP application.


Note:

If you are using NetBeans IDE 8.0, the SOAP Web Services plugin must be installed and activated.


To add a stub file:

  1. In the Projects window, expand the tree for a project, right-click the Source Packages node and select New, and then Other. Select the Java ME Embedded category and then Java ME Web Service Client.

  2. In the New Java ME Webservice Client page, you can do one of the following:

    • Click Running Web Service and enter the URL for the WSDL, and then click Retrieve WSDL.

    • Click Specify the Local filename for the retrieved WSDL and browse to find a file on your system.

    In either case, you must enter a package name (if it is not supplied), and then click Finish. The new package appears in the project and includes an interface file and a stub file.

  3. You can now edit your source files to call the content that the stub file provides, then build and run the project.

    For additional information about how to generate stub files and other supporting files from the command line, see Generating Stub Files from the Command Line.

Generating Stub Files from the Command Line

Mobile clients can use the Stub Generator to access web services. The wscompile tool generates stub files, ties, serializers, and WSDL files used in Java API for XML (JAX) RPC clients and services. The tool reads a configuration file that specifies a WSDL file, a model file, or a compiled service endpoint interface.

The wscompile.exe file is located under bin in the Java ME SDK installation directory. The syntax for the stub generator command is as follows:

wscompile <command> [options] <config_file>

The following commands for the wscompile tool are available:

Command Description

-gen

Same as -gen:client

-gen:client

Generates client artifacts (stubs, etc.)

-import

Generates interfaces and value types only


The following options for the wscompile tool are available:

Option Description

-d <output_dir>

Specifies where to place generated output files

-f:<features>

Enables the given features

-g

Generates debugging information

-features:<features>

Same as -f

-httpproxy:<host>:<port>

Specifies a HTTP proxy server (port defaults to 8080)

-model <file>

Writes the internal model to the given file

-O

Optimizes generated code

-s <dir>

Specifies where to place generated source files

-verbose

Outputs messages about what the compiler is doing

-version

Prints version information

-cldc1.0

Sets the CLDC version to 1.0 (default). Float and double become String.

-cldc1.1

Sets the CLDC version to 1.1. Float and double are OK.

-cldc1.0info

Shows all CLDC 1.0 information and warning messages.



Note:

Only one -gen option must be specified. The -f option requires a comma-separated list of features.


The wscompile tool can read WSDL files, compiled service endpoint interface (SEI) files, or model files as input. The following table lists features that can be specified with the -f option for the wscompile command, and the type of files that can be provided when the feature is specified. Multiple features must be separated by commas.

Option Description

explicitcontext

Turns on explicit service context mapping

nodatabinding

Turns off data binding for literal encoding

noencodedtypes

Turns off encoding type information

nomultirefs

Turns off support for multiple references

novalidation

Turns off full validation of imported WSDL documents

searchschema

Searches schema for subtypes

serializeinterfaces

Turns on direct serialization of interface types

wsi

Enables WSI-Basic Profile features (default)

resolveidref

Resolves xsd:IDREF

donotunwrap

No unwrap


The following are examples of using the wscompile command:

wscompile -gen -d generated config.xml
wscompile -gen -f:nounwrap -O -cldc1.1 -d generated config.xml