WebLogic Workshop provides several strategies for handling XML messages in web services. Which strategy you should use depends on how the web services you are designing fit into the overall application.
The strategy you should use when implementing a web service depends on two criteria:
The following diagram illustrates the matrix of strategies you may use depending on how your situation fits the preceding criteria:
In this scenario, you have existing business logic and data types you would like to expose as one or more web services, and there are no external restrictions on the interface you expose. Specifically, there are no pre-defined external data types or schema that you must support.
If the existing Java classes are suitable to be exposed in the public interface, the easiest approach in this situation is to use the classes directly as parameters and return values of the methods of your web service(s). WebLogic Workshop will automatically use default XML maps to express the data types as XML schema in the web service's WSDL file.
If the internal classes are not suitable to expose as public data types, define new types to be exposed in the public interface and then map the public types to the internal types using XQuery Maps by following the steps in Strategy C below.
In this scenario, there are no existing data structures and no external requirements. The easiest approach is to create XML schema describing the data types you would like to use in the public interface. Place these schema in the Schemas project in your application and use the resulting XMLBeans types for the parameters of your web service's methods. WebLogic Workshop will use your schemas for the data types in the web service's WSDL file.
In this scenario, the message formats for your web service's methods are specified externally but you have existing internal data types that you wish to use. To accomplish this, you need to use XQuery Maps to map the data in the incoming messages to fields in your internal data types. You can do this by following these steps:
Note: When you specify a schema-element as the incoming message format for a web service method, you are defining the complete message format for that method. If you want to share a single data type across multiple methods you must define a different outermost element for each method, each of which contains the shared data type. WebLogic Workshop maps incoming XML messages to web service operations based on the complete message schema, so message to method relationships must be one-to-one.
To learn more about XQuery Maps, see Introduction to XQuery Maps.
In this scenario, the data types in your web service's public interface are externally specified (in a WSDL file) and you have no existing internal types. In this case, you may use the data types defined in the WSDL directly, as follows:
None.