Package com.smartgwt.client.data

# Class WebService

java.lang.Object
com.smartgwt.client.core.BaseClass
com.smartgwt.client.data.WebService

All Implemented Interfaces:
  `HasHandlers`

public class WebService extends BaseClass
Class representing a WebService definition derived from a WSDL file.

A Web Service object allows you to invoke operations (via `callOperation()`), inspect schema declared in the WSDL file (`getSchema()`), and perform simple read-only databinding `getFetchDS()`.

Once a WebService has been loaded, a DataSource can be declared with a `serviceNamespace` to connect it to the web service, allowing DataSource data to be loaded and saved to the web service using `operationBindings`.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected JavaScriptObject`
  `jsObj`

  ### Fields inherited from class com.smartgwt.client.core.BaseClass

  `config, configOnly, factoryCreated, factoryProperties, id, scClassName`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WebService()`
  `WebService(JavaScriptObject jsObj)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `callOperation(String operationName, Map paramData, String resultType, WebServiceCallback callback)`
  Invoke a web service operation.
  `void`
  `callOperation(String operationName, Map paramData, String resultType, WebServiceCallback callback, WSRequest wsRequestProperties)`
  Invoke a web service operation.
  `JavaScriptObject`
  `create()`
  `static WebService`
  `get(String serviceNamespace)`
  Retrieve a WebService object by the targetNamespace declared on the <wsdl:definitions> element in the WSDL file from which the WebService was derived.
  `DataSource`
  `getFetchDS(String operationName, String resultType)`
  Retrieve a DataSource that provides read-only access to records returned by a web service operation.
  `DataSource`
  `getFetchDS(String operationName, String resultType, OperationBinding operationBindingProperties)`
  Retrieve a DataSource that provides read-only access to records returned by a web service operation.
  `DataSource`
  `getInputDS(String operationName)`
  Get a DataSource representing the input message to a web service operation.
  `JavaScriptObject`
  `getJsObj()`
  `JavaScriptObject`
  `getOrCreateJsObj()`
  `static WebService`
  `getOrCreateRef(JavaScriptObject jsObj)`
  `DataSource`
  `getSchema(String schemaName)`
  Get the schema definition of any complexType or element of complexType defined in any blocks in the WSDL file this WebService represents.
  `DataSource`
  `getSchema(String schemaName, String schemaType)`
  Get the schema definition of any complexType or element of complexType defined in any blocks in the WSDL file this WebService represents.
  `String`
  `getSoapMessage(WSRequest wsRequestProperties)`
  Return the SOAP message that will be formed from this WSRequest.
  `boolean`
  `isCreated()`
  `void`
  `setJavaScriptObject(JavaScriptObject jsObj)`
  `void`
  `setLocation(String url)`
  Set location can be used when the actual URL where a service will be accessible isn't known until runtime, or changes at runtime, hence can't be embedded in the service definition.
  `void`
  `setLocation(String url, String operation)`
  Set location can be used when the actual URL where a service will be accessible isn't known until runtime, or changes at runtime, hence can't be embedded in the service definition.

  ### Methods inherited from class com.smartgwt.client.core.BaseClass

  `addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoID, setConfig, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### jsObj

    protected JavaScriptObject jsObj

- ## Constructor Details

  - ### WebService

    public WebService()

  - ### WebService

    public WebService(JavaScriptObject jsObj)

- ## Method Details

  - ### getOrCreateRef

    public static WebService getOrCreateRef(JavaScriptObject jsObj)

  - ### getJsObj

    public JavaScriptObject getJsObj()
    Overrides:
      `getJsObj` in class `BaseClass`

  - ### isCreated

    public boolean isCreated()
    Overrides:
      `isCreated` in class `BaseClass`

  - ### getOrCreateJsObj

    public JavaScriptObject getOrCreateJsObj()
    Overrides:
      `getOrCreateJsObj` in class `BaseClass`

  - ### setJavaScriptObject

    public void setJavaScriptObject(JavaScriptObject jsObj)
    Overrides:
      `setJavaScriptObject` in class `BaseClass`

  - ### create

    public JavaScriptObject create()
    Specified by:
      `create` in class `BaseClass`

  - ### callOperation

    public void callOperation(String operationName, Map paramData, String resultType, WebServiceCallback callback)
    Invoke a web service operation.

    The `data` parameter will be serialized to XML to form the input message for
    the operation, as described by `XmlSerialize`. Namespacing,
    element ordering, and SOAP encoding rules are automatically followed. If the web
    service you are trying to contact requires a complicated nested structure, consider
    using `WSRequest.setUseFlatFields(Boolean)` to simplify the required JavaScript input data.

    The `resultType` selects what part of the message should be decoded to
    JavaScript and made available as the "data" variable in the callback. The
    `resultType` parameter can be either:

    - an XPath. "data" will be always be an Array, containing the selected elements as
      decoded by XMLTools.toJS. All properties will have String value.
    - the name of an XML Schema type found somewhere in the response. You can use the
      WSDL tab of the Developer Console to analyze the WSDL file for an appropriate type name.
      "data" will be an Array, containing the decoded elements as decoded by
      `DataSource.recordsFromXML(Object)` . In this case, since the XML Schema type of the
      selected data is known, properties will have correct type (eg "date" fields will
      have JavaScript Date objects)
    - null. "data" will an Object representing the entire &lt;SOAP:Body&gt; as decoded
      to JavaScript. As above, properties will have correct type.
    In the callback, you also receive the XML document returned by the web service as
    "xmlDoc".

    NOTE: `callOperation()` is appropriate for simple operations that do not
    involve DataBound Components, such as logging into a web service, or retrieving simple
    String data. `callOperation()` can also be used to retrieve small, read-only
    datasets such as the option list for a SelectItem, but only if the dataset is guaranteed
    to remain small enough for paging to be unnecessary. For any larger datasets or
    anything that will be edited, DataSource integration is more appropriate.

    Parameters:
      `operationName` - Name of the operation to invoke
      `paramData` - data to serialize as XML to form the inbound message of the operation
      `resultType` - Type, Element name, or XPath that should be selected from the result
      `callback` - Callback to invoke on completion

  - ### callOperation

    public void callOperation(String operationName, Map paramData, String resultType, WebServiceCallback callback, WSRequest wsRequestProperties)
    Invoke a web service operation.

    The `data` parameter will be serialized to XML to form the input message for
    the operation, as described by `XmlSerialize`. Namespacing,
    element ordering, and SOAP encoding rules are automatically followed. If the web
    service you are trying to contact requires a complicated nested structure, consider
    using `WSRequest.setUseFlatFields(Boolean)` to simplify the required JavaScript input data.

    The `resultType` selects what part of the message should be decoded to
    JavaScript and made available as the "data" variable in the callback. The
    `resultType` parameter can be either:

    - an XPath. "data" will be always be an Array, containing the selected elements as
      decoded by XMLTools.toJS. All properties will have String value.
    - the name of an XML Schema type found somewhere in the response. You can use the
      WSDL tab of the Developer Console to analyze the WSDL file for an appropriate type name.
      "data" will be an Array, containing the decoded elements as decoded by
      `DataSource.recordsFromXML(Object)` . In this case, since the XML Schema type of the
      selected data is known, properties will have correct type (eg "date" fields will
      have JavaScript Date objects)
    - null. "data" will an Object representing the entire &lt;SOAP:Body&gt; as decoded
      to JavaScript. As above, properties will have correct type.
    In the callback, you also receive the XML document returned by the web service as
    "xmlDoc".

    NOTE: `callOperation()` is appropriate for simple operations that do not
    involve DataBound Components, such as logging into a web service, or retrieving simple
    String data. `callOperation()` can also be used to retrieve small, read-only
    datasets such as the option list for a SelectItem, but only if the dataset is guaranteed
    to remain small enough for paging to be unnecessary. For any larger datasets or
    anything that will be edited, DataSource integration is more appropriate.

    Parameters:
      `operationName` - Name of the operation to invoke
      `paramData` - data to serialize as XML to form the inbound message of the operation
      `resultType` - Type, Element name, or XPath that should be selected from the result
      `callback` - Callback to invoke on completion
      `wsRequestProperties` - Additional properties for the WSRequest, such as HTTPHeaders

  - ### setLocation

    public void setLocation(String url)
    Set location can be used when the actual URL where a service will be accessible isn't known until runtime, or changes at runtime, hence can't be embedded in the service definition.
    With an operation parameter, setLocation() can be used to set a distinct URL for each web service operation. This is a development-time only feature that allows XML flat files to be placed at various URLs on a server, to serve as spoofed responses for each web service operation.
    Parameters:
      `url` - the URL where web service can be contacted

  - ### setLocation

    public void setLocation(String url, String operation)
    Set location can be used when the actual URL where a service will be accessible isn't known until runtime, or changes at runtime, hence can't be embedded in the service definition.
    With an operation parameter, setLocation() can be used to set a distinct URL for each web service operation. This is a development-time only feature that allows XML flat files to be placed at various URLs on a server, to serve as spoofed responses for each web service operation.
    Parameters:
      `url` - the URL where web service can be contacted
      `operation` - optional operation name to set the location for, for debugging only

  - ### getInputDS

    public DataSource getInputDS(String operationName)
    Get a DataSource representing the input message to a web service operation. This DataSource is suitable for use as form.dataSource for a form that the user fills out when providing inputs to call this web service operation.
    Parameters:
      `operationName` - name of the web service operation whose inputs the returned DataSource will represent
    Returns:
      DataSource representing the input message of a web service operation

  - ### getFetchDS

    public DataSource getFetchDS(String operationName, String resultType)
    Retrieve a DataSource that provides read-only access to records returned by a web service operation.
    DataBound Components can be bound to the returned DataSource, and the fetchData() method can be invoked to retrieve data from the web service.
    The returned DataSource is only capable of the "fetch" DataSource operation, not "update", "add" or "remove". To create a DataSource capable of full read-write access, use DataSource.operationBindings with the wsOperation property set to associate each DataSource operation with a web service operation.
    Parameters:
      `operationName` - name of the web service operation to invoke to fetch records
      `resultType` - tag or type name of the XML element to be returned as DataSource records
    Returns:
      dDataSource representing the fetch message of a web service operation

  - ### getFetchDS

    public DataSource getFetchDS(String operationName, String resultType, OperationBinding operationBindingProperties)
    Retrieve a DataSource that provides read-only access to records returned by a web service operation.
    DataBound Components can be bound to the returned DataSource, and the fetchData() method can be invoked to retrieve data from the web service.
    The returned DataSource is only capable of the "fetch" DataSource operation, not "update", "add" or "remove". To create a DataSource capable of full read-write access, use DataSource.operationBindings with the wsOperation property set to associate each DataSource operation with a web service operation.
    Parameters:
      `operationName` - name of the web service operation to invoke to fetch records
      `resultType` - tag or type name of the XML element to be returned as DataSource records
      `operationBindingProperties` - additional properties for the operationType:"fetch" operationBinding which this method automatically creates. This can be used to set properties such as `com.smartgwt.client.data.OperationBinding#setUseFlatFields(Boolean)` or `OperationBinding.setRecordXPath(String)`
    Returns:
      dDataSource representing the fetch message of a web service operation

  - ### getSchema

    public DataSource getSchema(String schemaName)
    Get the schema definition of any complexType or element of complexType defined in any blocks in the WSDL file this WebService represents.
    Parameters:
      `schemaName` - name of type or element
    Returns:
      requested schema

  - ### getSchema

    public DataSource getSchema(String schemaName, String schemaType)
    Get the schema definition of any complexType or element of complexType defined in any blocks in the WSDL file this WebService represents.
    Parameters:
      `schemaName` - name of type or element
      `schemaType` - optional type of schema to return, either "element" for xs:element definitions only or "type" for xs:complexType definitions. If unspecified, either will be returned, with types preferred if names collide
    Returns:
      requested schema

  - ### get

    public static WebService get(String serviceNamespace)
    Retrieve a WebService object by the targetNamespace declared on the <wsdl:definitions> element in the WSDL file from which the WebService was derived.
    Parameters:
      `serviceNamespace` - uri from the "targetNamespace" attribute of the <wsdl:definitions> element in the WSDL file
    Returns:
      the requested WebService, or null if not loaded

  - ### getSoapMessage

    public String getSoapMessage(WSRequest wsRequestProperties)
    Return the SOAP message that will be formed from this WSRequest.
    Parameters:
      `web` - service request object
    Returns:
      SOAP message