logo       

RE: Resolving types in imported schema: msg#00021

text.xml.xmlbeans.user

Subject: RE: Resolving types in imported schema

XMLBeans doesn't have "native" knowledge of any Schema types. When you pass in a SchemaTypeLoader as a parameter of compileXsd(), it has to be able to find any types for which you don't have the source file. In this case, since you don't have the source file for the Soap schema (as schemaLocation on import or as one of the arguments to .compileXsd), then the SchemaTypeLoader has to "know" about those types.
 
I happened to add at some time one SchemaTypeLoader specifically for working with SOAP but I only got as far as adding the soap:array attribute and soap:Array element.
So you have several choices:
 
1. add the SOAP Schema to the list of Schemas you are compiling
2. go ahead and submit a patch to add the soap:string type to the SoapEncSchemaTypeSystem (which would benefit the community and which I would be happy to review) and then use XmlBeans.typeLoaderUnion() to union that with the BuiltinTypeSystem
3. precompile the SOAP Schema into a jar and then use XmlBeans.typeLoaderUnion() and XmlBeans.typeLoaderForResource() to load the precompiled version from that jar.
 
Radu
 

From: Anil Edakkunni [mailto:anil.edakkunni@xxxxxxxxx]
Sent: Wednesday, November 08, 2006 2:23 PM
To: user@xxxxxxxxxxxxxxxxxxx
Subject: Resolving types in imported schema

Hi,

When I try to compile the following schema definition (which is part of a WSDL...):

<wsdl:definitions targetNamespace=" http://mydomain.com/testservice "
                  xmlns:impl="http://mydomain.com/testservice"
                  xmlns:wsdlsoap=" http://schemas.xmlsoap.org/wsdl/soap/ "
                  xmlns:apachesoap="http://xml.apache.org/xml-soap"
                  xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema "
                  xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <schema targetNamespace=" http://mydomain.com/testservice" xmlns=" http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/ "
>
            <import namespace=" http://schemas.xmlsoap.org/soap/encoding/"/>

            <complexType name="SOAPStruct">
                <sequence>
                    <element name="varInt" type="xsd:int"/>
                    <element name="varFloat" type="xsd:float"/>
                    <element name="varString" nillable="true" type="soapenc:string"/>
                </sequence>
            </complexType>

        </schema>

using the following code:

    public static SchemaTypeSystem compileSchema(Definition def) throws AppException {
        if (isDebug) LOG.debug("Compiling schema...");

        SchemaTypeSystem sts = null;

        Map nsDefs = def.getNamespaces();

        List schematas = ServiceUtils.getSchemata(def);

        if (schematas == null) {
            sts = null;
        } else {

            XmlObject [] xmloa = new XmlObject[schematas.size()];
            int i = 0;

            XmlOptions xmlopts = new XmlOptions();

            // For imported schematas
            xmlopts.setCompileDownloadUrls();

            xmlopts.setCompileNoUpaRule();

            // For NS prefixes defined in the WSDL element, and inherited into the schema element's scope.
            xmlopts.setLoadAdditionalNamespaces(nsDefs);

            //xmlopts.setCompileNoValidation();

            //xmlopts.setSaveImplicitNamespaces(nsDefs);
            //xmlopts.setSaveAggressiveNamespaces();
            //xmlopts.setSaveNamespacesFirst();


            Iterator it = schematas.iterator();
            while (it.hasNext()) {

                Schema si = (Schema) it.next();

                //addAdditionalNamespaces(si, nsDefs);

                try {
                    if (isDebug) LOG.debug("Parsing Schema: " + si.getDocumentBaseURI());

                    xmloa[i++] = XmlObject.Factory.parse(si.getElement(), xmlopts);
                } catch (XmlException e) {
                    throw new AppException("compileSchema: Error parsing schema: " + si.getDocumentBaseURI(), e);
                }

            }

            try {
                if (isDebug) LOG.debug("Compiling schemata...");

                sts = XmlBeans.compileXsd(xmloa,
                        XmlBeans.getBuiltinTypeSystem(),
                        xmlopts);

            } catch (XmlException xe) {
                throw new AppException("compileSchema: Error compiling schemata: ", xe);
            }

        }

        return sts;
    }

I get the following exception:

org.apache.xmlbeans.XmlException: error: src-resolve: type 'string@ http://schemas.xmlsoap.org/soap/encoding/' not found.


Can anyone tell me why?

I did add setCompileDownloadUrls() (per http://www.mail-archive.com/search?l=user%40xmlbeans.apache.org&q=import+error+src-resolve ) and tried a bunch of other XmlOptions, but it still is unable to resolve soapenc:string

Thanks in advance,
Anil.

P.S.
1. (UPDATE) The SOAP encoding schema types do get resolved successfully if I add a schemaLocation to the import element.


_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise