Spring 将文件映射到 Url / URI
我有一个 Spring Web 服务,其架构在目录中为:
- WebRoot/DataContract/person.xsd
- WebRoot/DataContract/sub-person.xsd
其中 sub-person.xsd 包含在 person.xsd 中,即:
在 Person 中。 xsd:
<xsd:import namespace="http://www.mynamespace.org/xml/sub-person"
schemaLocation="sub-person.xsd"/>
我已将 wsdl 定义为:
<bean id="personserv" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schemaCollection" ref="schemaCollection"/>
<property name="portTypeName" value="personserv"/>
<property name="locationUri" value="/ws/personnelService/"/>
<property name="targetNamespace" value="http://www.mynamespace.org/definitions"/>
</bean>
我可以使用以下方式访问 wsdl 文件:
http:// /localhost:8080/myapp/ws/personnelService/personserv.wsdl
但是,当使用此 wsdl 时,客户端可以获取 person.xsd,但无法获取 sub-person.xsd,并给出错误 failed to load
http://localhost:8080/myapp/ws/personnelService/sub-person.xsd
我的问题是如何使 sub-person.xsd 在该 URI 位置可用?
我还将 person.xsd 中指定的位置更改为:
<xsd:import namespace="http://www.mynamespace.org/xml/sub-person"
schemaLocation="/DataContract/sub-person.xsd"/>
客户端然后尝试在以下位置找到 sub-person.xsd:
http://localhost:8080/sub-person.xsd 这是不正确的。
另一种尝试是:
<xsd:import namespace="http://www.mynamespace.org/xml/sub-person"
schemaLocation="DataContract/sub-person.xsd"/>
客户端随后尝试在以下位置找到 sub-person.xsd:
http://localhost:8080/myapp/ws/personnelService/DataContract/sub-person.xsd
I have a spring webservice for which I have the schema in a directory as:
- WebRoot/DataContract/person.xsd
- WebRoot/DataContract/sub-person.xsd
Where sub-person.xsd is included in person.xsd that is:
in Person.xsd:
<xsd:import namespace="http://www.mynamespace.org/xml/sub-person"
schemaLocation="sub-person.xsd"/>
I have defined the wsdl as:
<bean id="personserv" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schemaCollection" ref="schemaCollection"/>
<property name="portTypeName" value="personserv"/>
<property name="locationUri" value="/ws/personnelService/"/>
<property name="targetNamespace" value="http://www.mynamespace.org/definitions"/>
</bean>
I can access the wsdl file using:
http://localhost:8080/myapp/ws/personnelService/personserv.wsdl
However, when making use of this wsdl the client can fetch person.xsd and cannot fetch sub-person.xsd giving an error failed to load
http://localhost:8080/myapp/ws/personnelService/sub-person.xsd
my question is how can I make sub-person.xsd available at the that URI location ?
I have also changed the location specified in person.xsd as:
<xsd:import namespace="http://www.mynamespace.org/xml/sub-person"
schemaLocation="/DataContract/sub-person.xsd"/>
which the client then tried to find sub-person.xsd at:
http://localhost:8080/sub-person.xsd which isn't correct.
Another attempt was:
<xsd:import namespace="http://www.mynamespace.org/xml/sub-person"
schemaLocation="DataContract/sub-person.xsd"/>
which the client then tried to find sub-person.xsd at:
http://localhost:8080/myapp/ws/personnelService/DataContract/sub-person.xsd
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Spring-WS 有这个 处理这个问题的非常好的工具,利用 Apache XML Commons 项目:
inline
属性是关键 - 它会读取每个模式文件,并且每当它找到import
或include
从一个到另一个的引用,它会将引用替换为引用文件的内容。这样做的效果是,WSDL 生成控制器的输出是一个单个文件,其中内联了所有模式信息,同时仍然使各种模式文件在服务器上保持独立。然后,您不必担心客户端是否可以追踪引用并正确解决它们,因为没有引用。
Spring-WS has this really nice facility for handling this, making use of the Apache XML Commons project:
The
inline
property is the key - it reads in each schema file, and whenever it finds animport
orinclude
reference from one to the other, it replaces the reference with the content of the referenced file.The effect of this is that the output of the WSDL-generation controller is a single file with all schema information inlined within it, while still keeping the various schema files separate on the server. You then don't have to worry about if the client can chase the references and resolve them properly, since there are no references.