views:

516

answers:

2

I tried to turn off importing documents in WSDL4J (1.6.2) in the way suggested by the API documentation:

  wsdlReader.setFeature("javax.wsdl.importDocuments", false);

In fact, it stops importing XML schema files declared with wsdl:import tag, but does stop importing files declared with xs:import tags.

The following code snippet [see at the end of the letter] for the example file

http://www.ibspan.waw.pl/~gawinec/example.wsdl

returns the following exception:

javax.wsdl.WSDLException: WSDLException (at /definitions/types/xs:schema):
faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced
at 'EchoExceptions.xsd', relative to
'http://www.ibspan.waw.pl/~gawinec/example.wsdl'.:
java.io.FileNotFoundException: This file was not found:
http://www.ibspan.waw.pl/~gawinec/EchoExceptions.xsd
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at IsolatedExample.main(IsolatedExample.java:15)
Caused by: java.io.FileNotFoundException: This file was not found:
http://www.ibspan.waw.pl/~gawinec/EchoExceptions.xsd
    at com.ibm.wsdl.util.StringUtils.getContentAsInputStream(Unknown Source)
    ... 10 more

Can you suggest me any solution to this problem? I just don't want to import external XML schemata.

Regards, Maciej


import javax.wsdl.WSDLException;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;

public class IsolatedExample {
  public static void main(String[] args) {

    WSDLFactory wsdlFactory;
    try {
      wsdlFactory = WSDLFactory.newInstance();
      WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
      wsdlReader.setFeature("javax.wsdl.verbose", false);
      wsdlReader.setFeature("javax.wsdl.importDocuments", false);
      wsdlReader.readWSDL("http://www.ibspan.waw.pl/~gawinec/example.wsdl");
    } catch (WSDLException e) {
      e.printStackTrace();
    }
  }
}
A: 

I haven't used Java for webservices, but have you tried setting an absolute path to the schemas you import? Perhaps it's trying to load a local file.

You could also try sniffing the wire to see if you're making a request, perhaps it's malformed.

$0.02

Leprechaun
A: 

A quick look at WSDL4J (it's been a while since I've worked directly with this project) suggests that there is no option specifically to prevent the reading of imported schemas. You may have stumbled upon on a bug in WSDL4J's mechanism of deserializing schemas. That said, if you're not interested in the contents of any schemas, including those inlined in the WSDL document, you can register your own extension registry (simply modify the PopulatedExtensionRegistry class to leave out the SchemaDeserializer).

Specifically, leave out the following lines:

mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_1999,
    SchemaImpl.class);
registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999,
    new SchemaDeserializer());
registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999,
    new SchemaSerializer());

mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2000,
    SchemaImpl.class);
registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000,
    new SchemaDeserializer());
registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000,
    new SchemaSerializer());

mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2001,
    SchemaImpl.class);
registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001,
    new SchemaDeserializer());
registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001,
    new SchemaSerializer());
Lawrence Mandel