I'm using JAX-WS for running some sample Web services. After publishing the web services, when I typed the WSDL URL, I could see the WSDL document. WSDL document refers a Schema document that goes like this:
<xs:schema version="1.0" targetNamespace="http://ts.ch01/">
<xs:element name="getTimeAsElapsed" type="tns:getTimeAsElapsed"/>
<xs:element name="getTimeAsElapsedResponse" type="tns:getTimeAsElapsedResponse"/>
<xs:element name="getTimeAsString" type="tns:getTimeAsString"/>
<xs:element name="getTimeAsStringResponse" type="tns:getTimeAsStringResponse"/>
−
<xs:complexType name="getTimeAsString">
<xs:sequence/>
</xs:complexType>
−
<xs:complexType name="getTimeAsStringResponse">
−
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
−
<xs:complexType name="getTimeAsElapsed">
<xs:sequence/>
</xs:complexType>
−
<xs:complexType name="getTimeAsElapsedResponse">
−
<xs:sequence>
<xs:element name="return" type="xs:long"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
My question is why is 'tns' appearing in the element declaration? For example:
<xs:element name="getTimeAsElapsed" type="
tns:getTimeAsElapsed"/>
I've nowhere is the schema document seeing 'tns' to be declared as namespace prefix, the schema document simply starts with
<xs:schema version="1.0" targetNamespace="http://ts.ch01/">
Then why 'tns' is appearing when referencing other elements? Is this by default behaviour of XML schema generated by JAX-WS?
As per w3, tns means "this namespace", referring to the current document. Not "tns" nor "this namespace" appears anyhere in the linked document. @rkedge yes, it does : "The “this namespace” (tns) prefix is used as a convention to refer to the current document."
tns stands for tns Namespace (short for Target Name Space) and if you will check any enterprise wsdl it is defined in the beginning <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:enterprise.soap.sforce. ...
An XML schema describes the structure of an XML document. A valid XML document must be formed and must be validated. A schema defines data types, which can be either simple or complex.
targetNamespace is the logical namespace for information about this service. WSDL documents can import other WSDL documents, and setting targetNamespace to a unique value ensures that the namespaces do not clash. xmlns is the default namespace of the WSDL document, and it is set to http://schemas.xmlsoap.org/wsdl/ .
As per w3, tns means "this namespace", referring to the current document.
Source: https://www.w3.org/TR/wsdl.html#_notational
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With