XML-Namespace - I know absolutely nothing about XML namespaces.

Posted on Wed Jan 3 08:22:59 2007 by owen
I know absolutely nothing about XML namespaces.
Hi. I can see why no one wants to post messages here. Have a look at what happens when you can't be bothered manually enclosing your text in markup. Good luck trying to decipher this stuff below. Hi. I'm wondering the following: If I have an XSD, and I then have a WSDL that tries to reference it, why is it that I get errors when I validate it? What have I done wrong? A repeat myself below with the documents included. If I have an XSD: <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.mydomain.com/NamespaceExperiment/types" xmlns:wcg="http://www.mydomain.com/NamespaceExperiment/types" elementFormDefault="qualified"> <!-- This is the start of the schema element declaration. --> <xsd:element name="id" type="xsd:string"/> <xsd:element name="item" type="wcg:ItemType"/> <xsd:complexType name="ItemType"> <xsd:sequence> <xsd:element ref="wcg:id"/> <xsd:element name="productName" type="xsd:string"/> <xsd:element name="price" type="xsd:double"/> <xsd:element name="quantity" type="xsd:integer"/> </xsd:sequence> </xsd:complexType> <xsd:element name="error" type="xsd:string"/> <!-- This is the end of the schema element declaration. --> </xsd:schema> An then I have a WSDL that <b>tries</b> to reference it: <?xml version="1.0" encoding="UTF-8"?> <definitions name="newWSDL" targetNamespace="http://www.mydomain.com/NamespaceExperiment" xmlns:tns="http://www.mydomain.com/NamespaceExperiment" xmlns:wcg="http://www.mydomain.com/NamespaceExperiment/types" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!-- Type definitions --> <types> <xsd:schema targetNamespace="http://www.mydomain.com/NamespaceExperiment/types"> <!-- TODO: type XML schema elements and types here, e.g.: --> <xsd:import namespace="http://www.mydomain.com/NamespaceExperiment" schemaLocation="H:\CurrentProjects\NoRepository\NamespaceExperiment\web\newXMLSchema.xsd"/> <!-- This is the end of the schema element declaration. --> </xsd:schema> </types> <!-- Message definitions --> <!-- TODO: write one or more messages here, e.g.: --> <message name ="newWSDLRequest"> <part name="id" element="wcg:id"/> </message> <!-- <message name ="newWSDLResponse"> <part name="item" element="wcg:item"/> </message> <message name ="newWSDLError"> <part name="error" element="wcg:error"/> </message> --> <!-- Port type definitions --> <!-- TODO: write one or more port types here (usually just one), e.g.: --> <!-- <portType name="newWSDLPortType"> <operation name="newWSDLOperation"> <input message="tns:newWSDLRequest"/> <output message="tns:newWSDLResponse"/> <fault message="tns:newWSDLError" name="error"/> </operation> </portType> --> <!-- Binding definitions --> <!-- TODO: write one or more bindings here (usually just one), e.g.: --> <!-- <binding name="newWSDLBinding" type="tns:newWSDLPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <operation name="newWSDLOperation"> <soap:operation soapAction="REPLACE_WITH_ACTION_URL"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> <fault name="error"> <soap:fault name="error" use="literal"/> </fault> </operation> </binding> --> <!-- Service and Port (network address) definitions --> <!-- TODO: write one or more service elements here (usually just one), e.g.: --> <!-- <service name="newWSDLService"> <port name="newWSDLPort" binding="tns:newWSDLBinding"> <soap:address location="REPLACE_WITH_ACTUAL_WEB_SERVICE_URL"/> </port> </service> --> </definitions> Why is it that I get errors when I validate it? What have I done wrong? XML validation started. H:/CurrentProjects/NoRepository/NamespaceExperiment/web/newWSDL.wsdl:25,4 In part "id", attribute element's value "wcg:id" is not a valid xml schema element available in this wsdl file. : Specify a valid schema element value for element attribute. H:/CurrentProjects/NoRepository/NamespaceExperiment/web/newXMLSchema.xsd:14,10 src-import.3.1: The namespace attribute, 'http://www.mydomain.com/NamespaceExperiment', of an <import> element information item must be identical to the targetNamespace attribute, 'http://www.mydomain.com/NamespaceExperiment/types', of the imported document. 2 Error(s), 0 Warning(s). XML validation finished.
Write a response