Changeset 8

Show
Ignore:
Timestamp:
02/12/07 08:44:33 (2 years ago)
Author:
kevin
Message:

fixing some holes in the doc

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/README.txt

    r7 r8  
    9898   a dictionary. Just return the value directly. 
    9999 
     100To instantiate and use your WebServicesRoot (MyService in the example above), you can do something like this: 
     101 
     102cherrypy.root = MyService("http://foo.bar.baz/") 
     103 
     104The constructor for WebServicesRoot has a required parameter of *baseURL*. This parameter sets the URL path of the web service (which will show up as the web service location in the WSDL). There are two optional parameters that will be derived from the baseURL if you don't provide them. Those parameters are *tns*  and *typenamespace*. *tns* is the target namespace declared in the WSDL (the XML namespace for the SOAP operations). *typenamepsace* is the XML namespace for the types defined in the WSDL. *tns* defaults to *baseURL* + "soap/". *typenamespace* defaults to *tns* + "types". 
     105 
     106URLs 
     107---- 
     108 
     109class InnerService(WebServicesRoot): 
     110    @wsexpose(int) 
     111    def times4(self, num): 
     112    return num * 4 
     113 
     114class ServiceRoot(WebServicesRoot): 
     115    inner = InnerService() 
     116 
     117    @wsexpose(int) 
     118    def times2(self, num): 
     119    return num * 2 
     120 
     121Assume that ServiceRoot is instantiated with a *baseURL* of "http://foo.bar.baz/". Here are URLs that are available: 
     122 
     123+----------------------------------+-------------------------------------------+ 
     124| URL                              | What is it                                | 
     125+==================================+===========================================+ 
     126| http://foo.bar.baz/              | nothing there... you could use standard   | 
     127|                                  | TurboGears expose to put a page there.    | 
     128+----------------------------------+-------------------------------------------+ 
     129| http://foo.bar.baz/times2        | HTTP access to the times2 method          | 
     130+----------------------------------+-------------------------------------------+ 
     131| http://foo.bar.baz/inner/times4  | HTTP access to the times4 method on       | 
     132|                                  | InnerService                              + 
     133+----------------------------------+-------------------------------------------+ 
     134| http://foo.bar.baz/soap/         | URL to POST SOAP requests to              | 
     135+----------------------------------+-------------------------------------------+ 
     136| http://foo.bar.baz/soap/api.wsdl | URL to get the WSDL file from             | 
     137+----------------------------------+-------------------------------------------+ 
     138 
     139SOAP method names are created by taking the URL parts and concatenating and 
     140camelCasing them. In the example above, there will be a "times2" SOAP method, 
     141as you'd expect. The "inner/times4" method will become "innerTimes4" in SOAP. 
     142All of the SOAP methods live in a flat namespace and appear in a single WSDL 
     143file that covers your whole web service. 
     144 
    100145Lists 
    101146-----