views:

715

answers:

3

I just now started learning web services.I cannot understand the use of xmlns:soap attribute of SOAP element.Thanks.

+2  A: 

Those "xmlns:" attributes are not specific to SOAP. They define prefixes that will later be used to refer to XML namespaces. Example:

<DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts" 
    DTS:ExecutableType="SSIS.Package.2">

This defines DTS as a prefix that means the namespace "www.microsoft.com/SqlServer/Dts". It then refers to the ExecutableType attribute from that namespace.

XML namespaces do the same job as a namespace in C# or C++. They provide a space in which to define names, so that names from one namespace do not conflict with names in another. You could define your own "ExecutableType" attribute, and it could mean something totally different from the one that Microsoft defined. Both could be used in the same document, with no ambiguity about which was which.

John Saunders
+1  A: 

quote from the W3C SOAP Spec should help here too

http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383497

A SOAP application SHOULD include the proper SOAP namespace on all elements and attributes defined by SOAP in messages that it generates. A SOAP application MUST be able to process SOAP namespaces in messages that it receives. It MUST discard messages that have incorrect namespaces (see section 4.4) and it MAY process SOAP messages without SOAP namespaces as though they had the correct SOAP namespaces.

SOAP defines two namespaces (see [8] for more information on XML namespaces):

•The SOAP envelope has the namespace identifier "http://schemas.xmlsoap.org/soap/envelope/" •The SOAP serialization has the namespace identifier "http://schemas.xmlsoap.org/soap/encoding/" A SOAP message MUST NOT contain a Document Type Declaration. A SOAP message MUST NOT contain Processing Instructions. [7]

+1  A: 

Based on the level of your question (Please don't take offense), it sounds like you are new to XML as well as XML based Web services. John Saunders correctly describes XML namespaces and their uses. If you are looking to get a better understanding of XML and XML based Web services, I recommend that you start with the W3 Schools' XML tutorial (specifically the section on XML namespaces).

The tutorial is located at: http://www.w3schools.com/xml/default.asp

The section on XML namespaces is located at: http://www.w3schools.com/xml/xml_namespaces.asp

DavidValeri