Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

66%
+2 −0
Q&A Validating xsd schema that contains import from external http source in Java 11

In the example.xsd file I have an import to an external xsd file that looks like this: <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.example.com" ...

0 answers  ·  posted 4y ago by Janar‭  ·  edited 4y ago by Monica Cellio‭

Question java spring xsd
#2: Post edited by user avatar Monica Cellio‭ · 2020-09-03T02:24:49Z (about 4 years ago)
Apparently wide code doesn't get a scrollbar right now and instead messes up the page formatting. I'm sorry; we'll get that fixed. Meanwhile trying this workaround so this page displays ok.
  • In the example.xsd file I have an import to an external xsd file that looks like this:
  • <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.example.com"
  • xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd">
  • <import namespace="http://ws-i.org/profiles/basic/1.1/xsd" schemaLocation="http://ws-i.org/profiles/basic/1.1/swaref.xsd" />
  • <element name="attachment" type="wsi:swaRef" />
  • </schema>
  • In the config file I have created the XsdSchema and validator beans
  • @Bean
  • public XsdSchema schema() {
  • return new SimpleXsdSchema(new ClassPathResource("example.xsd"));
  • }
  • @Bean
  • public XmlValidator schemaValidator(XsdSchema xsdSchema) {
  • return xsdSchema.createValidator()); // throws exception
  • }
  • when starting the server I get the following exception:
  • > schema_reference: Failed to read schema document 'swaref.xsd', because 'http' access is not allowed due to restriction set by the accessExternalSchema property.
  • In order to solve the problem I have tried different things such as:
  • - Setting `System.setProperty("javax.xml.accessExternalSchema", "all");`
  • - Setting `System.setProperty("javax.xml.accessExternalDTD", "all");`
  • - Creating jaxp.properties file under both jdk/lib and jdk/jre/lib and adding `javax.xml.accessExternalSchema = all` in there
  • - Changing import in xsd to `<import namespace="http://ws-i.org/profiles/basic/1.1/xsd"/>` which then causes different exception - Cannot resolve the name 'wsi:swaRef' to a(n) 'type definition' component.
  • Java 11, Gradle 5.5.1, Spring Boot 2.1.6, jaxws-ri 2.3.2
  • how to get it to work?
  • In the example.xsd file I have an import to an external xsd file that looks like this:
  • <schema xmlns="http://www.w3.org/2001/XMLSchema"
  • targetNamespace="http://test.example.com"
  • xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd">
  • <import namespace="http://ws-i.org/profiles/basic/1.1/xsd"
  • schemaLocation="http://ws-i.org/profiles/basic/1.1/swaref.xsd" />
  • <element name="attachment" type="wsi:swaRef" />
  • </schema>
  • In the config file I have created the XsdSchema and validator beans
  • @Bean
  • public XsdSchema schema() {
  • return new SimpleXsdSchema(new ClassPathResource("example.xsd"));
  • }
  • @Bean
  • public XmlValidator schemaValidator(XsdSchema xsdSchema) {
  • return xsdSchema.createValidator()); // throws exception
  • }
  • when starting the server I get the following exception:
  • > schema_reference: Failed to read schema document 'swaref.xsd', because 'http' access is not allowed due to restriction set by the accessExternalSchema property.
  • In order to solve the problem I have tried different things such as:
  • - Setting `System.setProperty("javax.xml.accessExternalSchema", "all");`
  • - Setting `System.setProperty("javax.xml.accessExternalDTD", "all");`
  • - Creating jaxp.properties file under both jdk/lib and jdk/jre/lib and adding `javax.xml.accessExternalSchema = all` in there
  • - Changing import in xsd to `<import namespace="http://ws-i.org/profiles/basic/1.1/xsd"/>` which then causes different exception - Cannot resolve the name 'wsi:swaRef' to a(n) 'type definition' component.
  • Java 11, Gradle 5.5.1, Spring Boot 2.1.6, jaxws-ri 2.3.2
  • how to get it to work?
#1: Initial revision by user avatar Janar‭ · 2020-09-02T23:01:40Z (about 4 years ago)
Validating xsd schema that contains import from external http source in Java 11
In the example.xsd file I have an import to an external xsd file that looks like this:

    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://test.example.com"
            xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd">
    <import namespace="http://ws-i.org/profiles/basic/1.1/xsd" schemaLocation="http://ws-i.org/profiles/basic/1.1/swaref.xsd" />
    <element name="attachment" type="wsi:swaRef" />
    </schema>

In the config file I have created the XsdSchema and validator beans

    @Bean
    public XsdSchema schema() {
      return new SimpleXsdSchema(new ClassPathResource("example.xsd"));
    }

    @Bean
    public XmlValidator schemaValidator(XsdSchema xsdSchema) {
      return xsdSchema.createValidator()); // throws exception
    }

when starting the server I get the following exception:
> schema_reference: Failed to read schema document 'swaref.xsd', because 'http' access is not allowed due to restriction set by the accessExternalSchema property.

In order to solve the problem I have tried different things such as:

 - Setting `System.setProperty("javax.xml.accessExternalSchema", "all");`
 - Setting `System.setProperty("javax.xml.accessExternalDTD", "all");`
 - Creating jaxp.properties file under both jdk/lib and jdk/jre/lib and adding `javax.xml.accessExternalSchema = all` in there
 - Changing import in xsd to `<import namespace="http://ws-i.org/profiles/basic/1.1/xsd"/>` which then causes different exception - Cannot resolve the name 'wsi:swaRef' to a(n) 'type definition' component.

Java 11, Gradle 5.5.1, Spring Boot 2.1.6, jaxws-ri 2.3.2

how to get it to work?