Export jar resources via website

I have a web service (with Spring -WS ).

I have a jar with several schemes (schema1.xsd, schema2.xsd and schema3.xsd) that I include in my web service.

Is there any way to populate the schemas from the jar through the servlet somehow in my wep web service application?

My Spring is MessageDispatcherServletdisplayed in / ws /

I would like my circuits to be exposed /schemas/schema1.xsd /schemas/schema2.xsd, etc.

I have an idea how to do this with a servlet, but it is too verbose and there should be a nicer way.

What I think has a servlet filter and everything that gets / schemes / checks to see if it is in my list of allowed resources and displays it.

This should be an agnostic server solution. (For example, http://tuckey.org/urlrewrite/ will not work).

Thank.

+3
source share
4 answers

I am again! Having seen the comments on your original question, I thought that I was proposing an alternative solution.

If I understand your problem, it looks like you have a WSDL (generated by Spring -WS) that contains links to various schemas. When a client tries to follow these schema links, it fails because there is no such resource.

Spring -WS offers a good way out of this, described in the section on WSDL exposure :

, , , CommonsXsdSchemaCollection, DefaultWsdl11Definition, :

<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
    <property name="xsds">
        <list>
            <value>classpath:/path/to/schema1.xsd</value>
            <value>classpath:/path/to/schema2.xsd</value>
        </list>
    </property>
    <property name="inline" value="true"/>
</bean>

, XSD WSDL. , .

, WSDL , . , .

+3

, : Spring ( , ), JAR ( Class.getResourceAsStream, ), "" HTTP- ( Apache Commons IO IOUtils.copy()).

, ( ).

:

@Controller
public class ResourceController {

    private Resource resource;

    @Required
    public void setResource(Resource resource) {
        this.resource = resource;
    }

    @RequestMapping
    public void handleRequest(HttpServletResponse httpResponse) throws IOException {
        InputStream resourceStream = resource.getInputStream();
        try {
            IOUtils.copy(resourceStream, httpResponse.getOutputStream());
        } finally {
            resourceStream.close();
        }
    }

}
+2

XSD schemas.war, web.xml -, . , .

0

, "", 4 , . , , , - , .

, xsd, wsdl DefaultWsdl11Definition, <sws:dynamic-wsdl> wsdl, xsd, , , . .NET- .

0

Source: https://habr.com/ru/post/1740047/


All Articles