7.1. |
How do I switch my webservice from the SOAP to the JSON protocol?
|
|
You just have to exchange some Javascript libraries. The stub implementations are compatible, so you don't have to
modify your Javascript code.
Replace the SOAP libraries
<script type="text/javascript" src="/core/script/xmlRequest.js"></script>
<script type="text/javascript" src="/core/script/webservice.js"></script>
<script type="text/javascript" src="/xml/wsscript/MyService.js"></script>
by the according JSON libraries (the build-time generated stub is replaced by its dynamic counterpart using the
pfx:wsscript tag)
<script type="text/javascript" src="/core/script/httpRequest.js"></script>
<script type="text/javascript" src="/core/script/webservice_json.js"></script>
<pfx:wsscript name="MyService"/> |
7.2. |
How to make a asynchronous webservice call?
|
|
Simply add, as an additional parameter, a function reference to the call of the appropriate webservice-object's method call:
webserviceObject.getRemoteSearchResult(queryString, callbackFunction);
Or create the webservice with an object reference as argument (whose methods will be called back automatically):
var search={
getRemoteSearchResult: function(result,requestid,exception) {
...
}
}
var service=new WS_SearchService(search);
service.getRemoteSearchResult(queryString); |
7.3. |
For what is requestID parameter in async-callback functions?
|
|
While synchronous calls are blocking and only can be made sequentially, asynchronous calls can be made simultaneously
and they can return in undetermined order. Using a requestID the application can control or manage the order of the
returning calls.
|
7.4. |
What are the different session types for in webservices.conf.xml?
|
|
The session type servlet indicates that the service request needs a valid Pustefix/HTTP session
(webservices which need to access ContextResources have to be of this type). Type none indicates that the service
needs no session.
|
7.5. |
How do I get access to the Context or Context Resources inside a webservice implementation?
|
|
A webservice gets access to the Context or ContextResources by deriving from
de.schlund.pfixcore.webservice.AbstractService and thus inheriting its access methods
getContext() and getContextResource() .
|
7.6. |
Which libraries have to be added?
|
|
None. All necessary libraries come bundled with Pustefix.
|
7.7. |
How to load multiple generated JSON stubs in a single file, within a single request?
|
|
Using pfx:wsscript you can request multiple stubs by specifying the servicenames as a whitespace-separated list.
<pfx:wsscript name="service1 service2 service3"/> | Be careful with the SOAP client |
---|
Never include the SOAP implementation code twice on a page! leads to strange "serializer not found exception"
|
|