java - 找不到 WSDL 文件架构位置

标签 java web-services spring wsdl

在尝试使用 soapUI 时,我收到错误消息,指出无法加载模式 request.xsd 这是我的 wsdl 的样子:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
              xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
              xmlns:schema="http://www.myweb/xml/webservice"
              xmlns:tns="http://www.myweb.com/xml/webservice"
              targetNamespace="http://www.myweb.com/xml/webservice">
<wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:import namespace="http://www.myweb.com/xml/webservice"                      
            schemaLocation="/WEB-INF/schemas/Request.xsd"/>
    </xsd:schema>

这是我的 spring 配置文件:

   <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:context="http://www.springframework.org/schema/context"   
xmlns:aop="http://www.springframework.org/schema/aop"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/aop
   http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<bean id="payloadMapping"   class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    <property name="defaultEndpoint" ref="inferenceEndPoint" />
    <property name="interceptors">
        <list>
            <ref local="validatingInterceptor" />
            <ref local="payLoadInterceptor" />
        </list>
    </property>
</bean>

<bean id="payLoadInterceptor"
    class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />

<bean id="validatingInterceptor"
    class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
    <description>
        This interceptor validates the incoming
        message contents
        according to the 'Request.xsd' XML
        Schema file.
    </description>
    <property name="schema" value="/WEB-INF/schemas/Request.xsd" />
    <property name="validateRequest" value="true" />
    <property name="validateResponse" value="false" />
</bean>

<bean id="mwsid" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
   <constructor-arg value="/WEB-INF/spring-ws.wsdl"/>
</bean>

<bean id="inferenceEndPoint" class="com.mywebsite.ws.web.InferenceEndPoint">
    <property name="messageService" ref="messageService" />
</bean>

<bean id="messageService" class="com.mywebsite.ws.service.MessageService">
    <property name="inferenceService" ref="inferenceService" />
</bean>

<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="/WEB-INF/schemas/Request.xsd" />
</bean>


<bean id="inferenceService" class="com.mywebsite.ws.im.InferenceService">
    <property name="webServiceConfiguration" ref="playerConfiguration" />
</bean>

<!-- <bean id="inferenceConfig" class="com.mywebsite.ws.im.InferenceService"> 
    <constructor-arg ref="playerConfiguration"/> </bean> -->

<!-- ~~~~~~~ Application beans ~~~~~~~ -->
<bean id="playerConfiguration"
    class="com.mywebsite.ws.configuration.WebServiceConfiguration"
    init-method="init">
    <property name="playerConfigXml" value="/WEB-INF/config/webserviceconfiguration.xml" />
    <property name="executingPathResource" value="/WEB-INF" />
    <property name="developmentMode" value="true" />
</bean>

最佳答案

我假设您正在通过从本地磁盘中选择 WSDL 创建一个新的 soapUI 项目。该工具正在读取文件并在到达 /WEB-INF/schemas/Request.xsd 时阻止,因为此路径告诉它转到根目录并查找名为 WEB 的目录-INF。在讨论案例时确保一致性也是明智的(文件说 Request.xsd 但您的问题陈述说 request.xsd;这在某些平台上很重要。

将 WSDL 中的导入更改为:

<xsd:import namespace="http://www.myweb.com/xml/webservice"                      
        schemaLocation="schemas/Request.xsd"/>

这假定 XSD 位于与 WSDL 相关的模式目录中。

关于java - 找不到 WSDL 文件架构位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6371090/

相关文章:

java - 在 Maven 项目中获取 Tomcat 依赖项错误

java - JAIN SIP 481 对 BYE 消息的响应

java - 将具有一个元素的 Java ArrayList 转换为 JSON 对象的问题

java - 无法在 Spring Boot Test 1.5 中设置运行时本地服务器端口

java - token ";"出现语法错误,JSP 中此 token 后应有表达式

java - 使用一元运算符之间的区别! if 语句中的 and (== false)

java - SOAPMessage 的字符串在 Java 中不起作用

java - 哪个版本的 oracle 瘦驱动程序与部署在 Websphere 7.0 上的应用程序一起使用

java - HIbernate 不会创建另一个数据库中已存在的表

java - Spring 在启动时忽略失败