Caché Class Definition Reference
SoapNameSpace
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Specifies the XML namespace used by a web method. Applies only in a class that is defined as a web service or web client.
Usage
To override the default XML namespace used by a method (when the method is used as a web method), use the following syntax:
Method name(formal_spec) As returnclass [ SoapNameSpace = "soapnamespace", WebMethod ]
{
   //implementation
}
Where soapnamespace is a namespace URI. Note that if the URI includes a colon (:), the string must be quoted. That is, you can use the following:
Method MyMethod() [ SoapNameSpace = "http://www.mynamespace.org", WebMethod ] 
Or the following:
Method MyMethod() [ SoapNameSpace = othervalue, WebMethod ] 
But not the following:
Method MyMethod() [ SoapNameSpace = http://www.mynamespace.org, WebMethod ] 
Important:
For a web service that you create manually, the default value of this keyword is usually suitable. When you generate a web client or service from a WSDL with the SOAP Wizard, Caché sets this keyword as appropriate for that WSDL; if you modify the value, your web client or service may no longer work.
Details
This keyword specifies the XML namespace used by this web method. For details, see Creating Web Services and Web Clients in Caché.
Note:
This keyword has an effect only if the method uses RPC-style binding. That is, the method (or the class that contains it) must be marked with SoapBindingStyle equal to rpc. (If you specify this keyword for a method that uses document-style binding, the WSDL will not be self-consistent.)
Default
If you omit this keyword, the method is in the namespace specified by the NAMESPACE parameter of the web service or client class.
Relationship to WSDL
For a Caché web service, the SoapNameSpace keyword affects the namespace declarations within the <definitions> element. The namespace that you specify (for example, http://www.customtypes.org) is added here. For example:
...
xmlns:ns2="http://www.customtypes.org" 
xmlns:s0="http://www.wsns.org" 
...
targetNamespace="http://www.wsns.org"
The http://www.customtypes.org namespace is assigned to the prefix ns2 in this example.
Notice that the WSDL also declares, as usual, the namespace of the web service (http://www.wsns.org). This namespace is assigned to the prefix s0 in this example and is also used as the target namespace.
Effect on SOAP Messages
A possible SOAP message might look as follows (with line breaks and spaces added for readability):
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' 
                   xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
                   xmlns:s='http://www.w3.org/2001/XMLSchema' 
                   xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' 
                   xmlns:tns='http://www.customtypes.org' >
   <SOAP-ENV:Body SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
      <tns:AddResponse>
         <AddResult>42</AddResult>
      </tns:AddResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Notice that the <AddResponse> element is in the http://www.webservicetypesns.org namespace.
In contrast, if we did not specify the SoapNameSpace keyword, the message would be as follows instead:
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' 
                   xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
                   xmlns:s='http://www.w3.org/2001/XMLSchema' 
                   xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' 
                   xmlns:tns='http://www.wsns.org' >
   <SOAP-ENV:Body SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
      <tns:AddResponse>
         <AddResult>42</AddResult>
      </tns:AddResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In this case, the <AddResponse> element is in the namespace http://www.wsns.org, the namespace of the web service.
See Also