Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsNo targetnamespace set for local elements inside complextype
https://www.eclipse.org/forums/index.php/mv/msg/23936/77496/#msg_77496
I have defined a complextype in an wsdl inside <types> section under
schema, as below :
------------------------------------------------------------ -----------
test.wsdl
------------------------------------------------------------ -----------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/test/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="test"
targetNamespace="http://www.example.org/test/">
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/test/">
<xsd:complexType name="ct1">
<xsd:sequence>
<xsd:element name="ele1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
</wsdl:definitions>
------------------------------------------------------------ -----------
Now i am using below code snippet :
------------------------------------------------------------ -----------
String sourceLoc = "C:\\test.wsdl";
File file1 = new File(sourceLoc);
final ResourceSet resourceSet = new ResourceSetImpl();
final Resource res1 =
resourceSet.getResource(URI.createURI(file1.toURI().toString ()), true);
WSDLResourceImpl wsdlr = (WSDLResourceImpl)res1;
Definition definition = wsdlr.getDefinition();
Types types = definition.getETypes();
XSDSchema schema = (XSDSchema) types.getSchemas().get(0);
XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)
schema.getTypeDefinitions().get(0);
final XSDElementDeclaration element =
(XSDElementDeclaration)((XSDModelGroup)((XSDParticle)complex Type.getContent()).getContent()).
getContents().iterator().next().getContent();
------------------------------------------------------------ -----------
So now when i get the targetNamespace for ele1 which is defined in complex
type "ct1" then it is returnd as "null", where as it should be
"http://www.example.org/test/".
This case works fine when we have this schema defined in an XSD file and
process it ??
It seems there is something wrong in the "XSDSchema" which is returned by
wsdl "Definition".
--
Thanks and best regards,
Bhuvan Mehta]]>Bhuvan Mehta2009-03-19T11:33:31-00:00Re: No targetnamespace set for local elements inside complextype
https://www.eclipse.org/forums/index.php/mv/msg/23936/77519/#msg_77519
Comments below.
Bhuvan wrote:
> Hello,
>
> I have defined a complextype in an wsdl inside <types> section under
> schema, as below :
> ------------------------------------------------------------ -----------
> test.wsdl
> ------------------------------------------------------------ -----------
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://www.example.org/test/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="test"
> targetNamespace="http://www.example.org/test/">
> <wsdl:types>
> <xsd:schema targetNamespace="http://www.example.org/test/">
> <xsd:complexType name="ct1">
> <xsd:sequence>
> <xsd:element name="ele1" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
> </wsdl:types>
> </wsdl:definitions>
> ------------------------------------------------------------ -----------
>
> Now i am using below code snippet :
> ------------------------------------------------------------ -----------
> String sourceLoc = "C:\\test.wsdl";
>
> File file1 = new File(sourceLoc);
> final ResourceSet resourceSet = new ResourceSetImpl();
> final Resource res1 =
> resourceSet.getResource(URI.createURI(file1.toURI().toString ()), true);
> WSDLResourceImpl wsdlr = (WSDLResourceImpl)res1;
> Definition definition = wsdlr.getDefinition();
> Types types = definition.getETypes();
> XSDSchema schema = (XSDSchema) types.getSchemas().get(0);
> XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)
> schema.getTypeDefinitions().get(0);
> final XSDElementDeclaration element =
> (XSDElementDeclaration)((XSDModelGroup)((XSDParticle)complex Type.getContent()).getContent()).
>
>
> getContents().iterator().next().getContent();
>
> System.out.println(element.getName());
> System.out.println(element.getTargetNamespace());
>
> ------------------------------------------------------------ -----------
> So now when i get the targetNamespace for ele1 which is defined in
> complex type "ct1" then it is returnd as "null", where as it should be
> "http://www.example.org/test/".
No, local element declarations by default have form="unqualified" and
the schema itself by default has elementFormDefault="unqualified" so
unless you take explicit action to set one of these two things to
"qualified" the element will be unqualified and hence will have null
target namespace.
>
> This case works fine when we have this schema defined in an XSD file
> and process it ??
It will work the same way or are you asserting otherwise?
>
> It seems there is something wrong in the "XSDSchema" which is returned
> by wsdl "Definition".
No, I think your expectations are incorrect.
>
> --
> Thanks and best regards,
> Bhuvan Mehta
>]]>Ed Merks2009-03-19T12:17:44-00:00Re: No targetnamespace set for local elements inside complextype
https://www.eclipse.org/forums/index.php/mv/msg/23936/604133/#msg_604133
Comments below.
Bhuvan wrote:
> Hello,
>
> I have defined a complextype in an wsdl inside <types> section under
> schema, as below :
> ------------------------------------------------------------ -----------
> test.wsdl
> ------------------------------------------------------------ -----------
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://www.example.org/test/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="test"
> targetNamespace="http://www.example.org/test/">
> <wsdl:types>
> <xsd:schema targetNamespace="http://www.example.org/test/">
> <xsd:complexType name="ct1">
> <xsd:sequence>
> <xsd:element name="ele1" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
> </wsdl:types>
> </wsdl:definitions>
> ------------------------------------------------------------ -----------
>
> Now i am using below code snippet :
> ------------------------------------------------------------ -----------
> String sourceLoc = "C:\\test.wsdl";
>
> File file1 = new File(sourceLoc);
> final ResourceSet resourceSet = new ResourceSetImpl();
> final Resource res1 =
> resourceSet.getResource(URI.createURI(file1.toURI().toString ()), true);
> WSDLResourceImpl wsdlr = (WSDLResourceImpl)res1;
> Definition definition = wsdlr.getDefinition();
> Types types = definition.getETypes();
> XSDSchema schema = (XSDSchema) types.getSchemas().get(0);
> XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)
> schema.getTypeDefinitions().get(0);
> final XSDElementDeclaration element =
> (XSDElementDeclaration)((XSDModelGroup)((XSDParticle)complex Type.getContent()).getContent()).
>
>
> getContents().iterator().next().getContent();
>
> System.out.println(element.getName());
> System.out.println(element.getTargetNamespace());
>
> ------------------------------------------------------------ -----------
> So now when i get the targetNamespace for ele1 which is defined in
> complex type "ct1" then it is returnd as "null", where as it should be
> "http://www.example.org/test/".
No, local element declarations by default have form="unqualified" and
the schema itself by default has elementFormDefault="unqualified" so
unless you take explicit action to set one of these two things to
"qualified" the element will be unqualified and hence will have null
target namespace.
>
> This case works fine when we have this schema defined in an XSD file
> and process it ??
It will work the same way or are you asserting otherwise?
>
> It seems there is something wrong in the "XSDSchema" which is returned
> by wsdl "Definition".
No, I think your expectations are incorrect.
>
> --
> Thanks and best regards,
> Bhuvan Mehta
>]]>Ed Merks2009-03-19T12:17:44-00:00