• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

targetNamespace and imports

 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can I have a situation where my schema targetNamespace(http://y.com) inside the wsdl types is different from the targetNamespace(http://x.com) of wsdl definitions?

Consider a wsdlA:

wsdlA.wsdl
----------
<definitions name="wsdlA"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://x.com">
<types>
<xsd:schema targetNamespace="http://y.com">
<xsd:simpleType name="xstring">
<xsd:restriction base="xsd:string">
<xsd attern value="[1-9]{1}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
</types>
<message name="mymessage">
<part name="str" type="xsd:string"/>
</message>

</definitions>


now if I want to import wsdlA into wsdlB
1. should I import the targetnamespace(http://y.com) of schema inside wsdlA or


wsdlb.wsdl
----------


<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:y="http://y.com">

<import namespace="http://y.com" location="wsdla"/>

<message name="mymessage">
<part name="input" type="y:xstring"/>
</message>

</definitions>



2. should I import the targetNamespace(http://x.com) of the wsdlA?


<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:x="http://x.com">

<import namespace="http://x.com" location="default/wsdla"/>

<message name="mymessage">
<part name="input" type="x:xstring"/>
</message>

</definitions>

Well I check with some editor, the second option works fine.
Any explanations?
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The namespace attribute of the import statement must match the targetNamespace of the schema.
Import vs. include
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vasim Patel:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:y="http://y.com">

<import namespace="http://y.com" location="wsdla"/>


WSDL import is based on the XML Schema import. Your import violates two rules Schema Representation Constraint: Import Constraints and Semantics:
  • 1.1 If the namespace [attribute] is present, then its �actual value� must not match the �actual value� of the enclosing <schema>'s targetNamespace [attribute]; i.e. it cannot be "http://y.com".
  • 3.1 If there is a namespace [attribute], then its �actual value� must be identical to the �actual value� of the targetNamespace [attribute] of the <schema> item; i.e. its must be "http://x.com" - the subschema does not play a role here.

  • If you want to share the type definition simply but that in an XML Schema document (for a separate namespace) and import that into the WSDLs.
    To get something into your namespace you will have to use include.
     
    wise owen
    Ranch Hand
    Posts: 2023
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Also, the WS-I Basic Profile provides a few guides to use wsdl:import to import WSDL files and use xs:import to import XML schemas.
    [ February 07, 2006: Message edited by: wise owen ]
     
    Vasim Patel
    Ranch Hand
    Posts: 87
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks very much Peer and Wise
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic