|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface WsdlBinding
XMLTools.loadXMLSchema(java.lang.String, com.smartgwt.client.data.XSDLoadCallback)
(contained in WSDL,
or external),
including translating XML Schema "restrictions" to ISC Validator
WSDL services can be contacted by using
XMLTools.loadWSDL(java.lang.String, com.smartgwt.client.data.WSDLLoadCallback)
or the
'<isc:loadWSDL> JSP tag'
to load the service definition, then
invoking methods on the resulting WebService
object.
WebService.callOperation(java.lang.String, java.util.Map, java.lang.String, com.smartgwt.client.data.WebServiceCallback)
can
be used to manually invoke operations for
custom processing (example using
${isc.DocUtils.linkForExampleId('wsdlOperation', 'public zipcode service')},
examples using .NET at
/examples/databinding/dotNET/temperatureConvert.jsp).
Fetch-only DataSource binding
To bind a component to a web service operation, call
WebService.getFetchDS(java.lang.String, java.lang.String)
to obtain a DataSource which describes the structure of an
XML element or XML Schema type
named elementName, which appears in the response message for the operation
named
operationName. A component bound to this DataSource will show fields corresponding
to the
structure of the chosen XML element or type, that is, one field per subelement or
attribute. ListGrid.fetchData()
called on this DataSource (or on a
component bound to it) will
invoke the specified web service operation, using the
Criteria
passed to
fetchData() to fill out the input message via
DataSource.xmlSerialize(com.google.gwt.core.client.JavaScriptObject)
, and using
the specified XML element from the response
message as data.
Similarly, WebService.getInputDS(java.lang.String)
returns
a DataSource suitable for binding to a form that a user
will fill out to provide inputs to
the specified web service operation. Typical use is to let the user fill in the
form, then
pass the results of DynamicForm.getValues()
to
ListGrid.fetchData()
as criteria.
If the input message to the web service
has extra nesting, consider using
the 'useFlatFields'
property to simplify the inputs
required for fetchData()
, and/or to simplify form
databinding via
'component.useFlatFields'
.
Note that the WSDL tab in the Developer Console can provide a clean,
simplified view of any
WSDL file, making it easier to pick out the appropriate operationName
and
elementName
parameters to pass to getFetchDS()
and other
WebService
methods.
Take a look at the ${isc.DocUtils.linkForExampleId('wsdlBinding', 'Google SOAP Search example')} and the .NET example (/examples/databinding/dotNET/customerSearch.jsp).
Binding with Customized Presentation
Because XML Schema lacks key presentation metadata such as user-viewable titles, typically you cannot directly use the DataSources derived from XML Schema embedded in a WSDL file to drive visual component DataBinding in your final application.
You can create a DataSource that has custom fields and invokes a
web
service operation by setting serviceNamespace
to match the targetNamespace
of the WebService
(found on the
<definitions>
element from the
WSDL file), and setting 'wsOperation'
to the name of the
web service operation to
invoke. fetchData()
called on such a DataSource will
invoke the web service operation named by 'wsOperation'
,
just like a DataSource returned by WebService.getFetchDS(java.lang.String, java.lang.String)
.
In contrast to getFetchDS()
, creating a
DataSource in this way gives you the
opportunity to:
'operationBinding.recordXPath'
and
'field.valueXPath'
, and transform it with
DataSource.transformResponse(com.smartgwt.client.data.DSResponse, com.smartgwt.client.data.DSRequest, java.lang.Object)
startRow
for paging, or a sessionId for
a service requiring authentication
XML Schema Reuse
Having loaded a WSDL file, all of the XML Schema definitions within the service definition
get translated to Smart GWT DataSource
and
SimpleType
via the rules described by XMLTools.loadXMLSchema(java.lang.String, com.smartgwt.client.data.XSDLoadCallback)
,
and are available to you via WebService.getSchema(java.lang.String)
and type
.
You can use the inheritsFrom
property to create
DataSources that extend
from XML schema definitions, then add presentation metadata not found in XML schema.
Even if you choose to declare all fields manually, you can leverage XML Schema
<simpleType>
definitions by setting 'field.type'
to the name
of an XML
Schema simple type embedded in the WSDL file.
Round Trip Binding [fetch -> edit -> save]
For full read-write integration with a service that supports the basic
'DataSource operations'
on persistent data,
OperationBinding
can be declared for each DataSource operation, and
the 'wsOperation'
property can be used to to bind each
'DataSource operation'
(fetch, update, add, remove) to a
corresponding web service operation.
For example, this code accomplishes part of the binding to the SalesForce partner web services (additional code is required to handle authentication and other details):
isc.DataSource.create({ serviceNamespace : "urn:partner.soap.sforce.com", operationBindings : [ { operationType:"fetch", wsOperation:"query", recordName: "sObject" }, { operationType:"update", wsOperation:"update", recordName: "SaveResult" }, { operationType:"add", wsOperation:"create", recordName: "SaveResult" }, { operationType:"remove", wsOperation:"delete", recordName: "DeleteResult" } ], ... });NOTE: additional code is required to handle authentication and other details, see the complete code in isomorphicSDK/examples/databinding/SalesForce.
In this usage, any DSRequest
performed on this DataSource invokes the web service operation
named by the wsOperation
property on
the corresponding operationBinding, and
data
is serialized via
DataSource.xmlSerialize(com.google.gwt.core.client.JavaScriptObject)
to form the input
message to send to the web service. For
example, if a DynamicForm.saveData()
is
invoked and triggers a DSRequest
with operationType:"add", the DataSource above will invoke
the "create" operation, and DynamicForm.getValues()
will become
data
and be serialized to form the input message of the "create" web
service operation.
Typical usage is:
inheritsFrom
.
OperationBinding
to configure the entity DataSource
to
call the appropriate web service operations for each DataSource operation, and extract
results via
'recordXPath'
/'recordName'
ListGrid
to the entity DataSource
SearchForm
to the input message of the fetch operation
(obtained via WebService.getInputDS(java.lang.String)
. This is
done because search inputs are frequently unrelated to
the structure of the objects being
searched for
DataSource.transformRequest(com.smartgwt.client.data.DSRequest)
/DataSource.transformResponse(com.smartgwt.client.data.DSResponse, com.smartgwt.client.data.DSRequest, java.lang.Object)
,
useFlatFields
and responseDataSchema
to
handle inconsistencies
between the WSDL operations and the data you want in the presentation
layer.
This requires a SalesForce account. SalesForce currently offers free developer accounts. Please note: this application deals with live data and if you using inline editing it will save to SalesForce.
Deployment
For best performance, using the '<isc:loadWSDL> JSP tag'
is recommended, as it automatically caches a
translated form of the WSDL file. If you are
not using the Smart GWT server, the WSDL tab in the Developer Console
allows you
to save a .js file representing a WebService object, which can then be loaded and cached
like a
normal JavaScript file.
Creating New WSDL Services
If you have no existing WSDL web
service but would like to use web services for integration,
you can implement the "Smart GWTOperations" web service
described by the
${isc.DocUtils.externalLink(isc.Page.getIsomorphicDir()+"system/schema/Smart
GWTOperations.wsdl","WSDL file")}
included in the SDK. This simple, 4 operation web service can support any
number of
DataSources. In this case, you create your DataSources as client-side instances of
WSDataSource
(general client-side DataSource creation is described under
'Creating DataSources'
). To change the URL where ISC
expects to
find the Smart GWTOperations web service, use WebService.setLocation(java.lang.String)
like
so:
var service = isc.WebService.get("urn:operations.smartclient.com"); service.setLocation("myURL");
To implement a web service starting from a WSDL file:
DataSource.getServiceNamespace()
,
DataSource.getSchemaNamespace()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |