Skip to main content
Previous sectionNext section

SoapTypeNameSpace

Specifies the XML namespace for the types used by this web method. Applies only in a class that is defined as a web service or web client.

Usage

To override the default XML namespace for the types (when the method is used as a web method), use the following syntax:

Method name(formal_spec) As returnclass [ SoapTypeNameSpace = "soapnamespace", SoapBindingStyle = document, 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() [ SoapTypeNameSpace = "http://www.mynamespace.org", SoapBindingStyle = document, WebMethod ] 
Copy code to clipboard

Or the following:

Method MyMethod() [ SoapTypeNameSpace = othervalue, SoapBindingStyle = document, WebMethod ] 
Copy code to clipboard

But not the following:

Method MyMethod() [ SoapTypeNameSpace = http://www.mynamespace.org, SoapBindingStyle = document, WebMethod ] 
Copy code to clipboard
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 a 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 for the types 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 document-style binding. That is, the method (or the class that contains it) must be marked with SoapBindingStyle equal to document. (It is meaningless to specify this keyword for a method that uses rpc-style binding.)

Default

If you omit this keyword, the types for this method are in the namespace specified by the TYPENAMESPACE parameter of the web service or client class. If TYPENAMESPACE is not specified, the types are instead in the namespace specified by the NAMESPACE parameter of the web service or client.

Relationship to WSDL

The SoapTypeNameSpace keyword affects the following parts of the WSDL:

  • 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.wbns.org" 
    xmlns:s1="http://webservicetypesns.org" 
    ...
    targetNamespace="http://www.wbns.org"
    Copy code to clipboard

    The http://www.customtypes.org namespace is assigned to the prefix ns2 in this example.

    Notice that the WSDL also declares the following namespaces as usual:

    • The namespace of the Web service (http://www.wsns.org), which is assigned to the prefix s0 in this example and which is also used as the target namespace for the Web service.

    • The types namespace of the Web service (http://www.webservicetypesns.org), which is assigned to the prefix s1 in this example.

      If no types namespace is specified in the web service class, this namespace is not included in the WSDL.

  • The <types> element, which includes a <schema> element whose targetNamespace attribute equals the namespace you specified for SoapTypeNameSpace:

    <types>
    ...
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.customtypes.org">
        <s:element name="Add">
            <s:complexType>
                <s:sequence>
                    <s:element minOccurs="0" name="a" type="s:decimal"/>
                    <s:element minOccurs="0" name="b" type="s:decimal"/>
                </s:sequence>
            </s:complexType>
        </s:element>
        <s:element name="AddResponse">
            <s:complexType>
                <s:sequence>
                    <s:element name="AddResult" type="s:decimal"/>
                </s:sequence>
            </s:complexType>
        </s:element>
    </s:schema>
    
    ...
    </types>
    Copy code to clipboard

    In contrast, if you did not specify SoapTypeNameSpace, this part of the WSDL would be as follows instead. Notice that the targetNamespace for the <schema> element is the namespace of the types for the web service:

    <types>
    ...
    <s:schema elementFormDefault="qualified" targetNamespace="http://www.webservicetypesns.org">
        <s:element name="Add">
            <s:complexType>
                <s:sequence>
                    <s:element minOccurs="0" name="a" type="s:decimal"/>
                    <s:element minOccurs="0" name="b" type="s:decimal"/>
                </s:sequence>
            </s:complexType>
        </s:element>
        <s:element name="AddResponse">
            <s:complexType>
                <s:sequence>
                    <s:element name="AddResult" type="s:decimal"/>
                </s:sequence>
            </s:complexType>
        </s:element>
    </s:schema>
    
    ...
    </types>
    Copy code to clipboard

    (Also, if no types namespace is specified in the web service class, the targetNamespace would instead be the namespace of the web service.)

Effect on 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'>
   <SOAP-ENV:Body>
      <AddResponse xmlns="http://www.customtypes.org">
         <AddResult>3</AddResult>
      </AddResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copy code to clipboard

Notice that the <AddResponse> element is in the "http://www.customtypes.org" namespace.

In contrast, if we did not specify the SoapTypeNameSpace keyword, the message could 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'>
   <SOAP-ENV:Body>
      <AddResponse xmlns="http://www.webservicetypesns.org">
         <AddResult>3</AddResult>
      </AddResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Copy code to clipboard

See Also