Search code examples
javawsdljavax

Generate javax.wsdl.Definition from a String or byte array


I have a wsdl stored in a string/byte array. Is there a way to generate javax.wsdl.Definition from a String or byte array ? I checked the documentation here but couldn't find a way to do this.

Any samples or pointers ?


Solution

  • Found the answer:

    public void getWSDLDefinition(byte[] wsdl) {
            try {
                WSDLReader wsdlReader = javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
                // switch off the verbose mode
                wsdlReader.setFeature(JAVAX_WSDL_VERBOSE_MODE, false);
                wsdlReader.setFeature("javax.wsdl.importDocuments", false);
                Definition wsdlDefinition = wsdlReader.readWSDL(null, new InputSource(new ByteArrayInputStream(wsdl)));
            } catch (Exception e) {}
        }