在 WSDL 文件中找不到 Xsd 架构位置

发布于 2024-11-15 18:34:04 字数 8305 浏览 1 评论 0原文

这个问题已经三天了仍然没有解决,如果有人能提供帮助,我真的很感激,下面是所有代码。

问题是:如果我将 wsdl 文件(位于我的 eclipse 项目目录中)从硬盘显示到soapUI,则此 Web 服务运行良好。 它无法找到请求架构文件

http://localhost:8080/mwp/mws/mwsid.wsdl

但如果我将 url 指定为:这会正确公开 wsdl 但无法找到架构,则

,我从soapUI 中收到错误:错误:无法加载 url [http://localhost:8080/mwp /mws/Request.xsd]

这是 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">

<description>
</description>

<bean id="webServicePluginDescriptor"
    class="com.mywebsite.ws.configuration.mtchWebservicePluginDescriptor" />

<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">

    <property name="schema"
        value="classpath:/wsdl/Request.xsd" />
    <property name="validateRequest" value="true" />
    <property name="validateResponse" value="false" />
</bean>

<bean id="PropertyResource" class="com.mywebsite.ws.im.PropertyResource">
    <property name="resource"
        value="/WEB-INF/client-specific/InferenceMachine.properties" />
</bean>

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

<bean id="messageWebService" class="com.mywebsite.ws.service.MessageWebService"
    scope="request">
    <aop:scoped-proxy />
    <property name="inferenceService" ref="inferenceService" />
</bean>

<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="classpath:/wsdl/Request.xsd" />
</bean>

<bean id="mwsid"
    class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="classpath:/wsdl/mtchwsdl.wsdl" />
</bean>

<bean id="inferenceService" class="com.mywebsite.ws.im.InferenceService"
    scope="request">
    <aop:scoped-proxy />
    <property name="webServiceConfiguration" ref="wsPlayerConfiguration" />

    <property name="properties">
        <bean class="com.mywebsite.ws.im.PropertyResource">
            <property name="resource"
                value="/WEB-INF/client-specific/InferenceMachine.properties" />
        </bean>
    </property>
</bean>

<!-- ~~~~~~~ Application beans ~~~~~~~ -->
<bean id="wsPlayerConfiguration"
    class="com.mywebsite.ws.configuration.WebServiceConfiguration"
    scope="request">
    <aop:scoped-proxy />
    <property name="playerConfiguration" ref="playerConfiguration"></property>
    <property name="configurationSetup" ref="configurationSetup"></property>
</bean>

这是 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.mywebsitex.com/xml/webservice"
              xmlns:tns="http://www.mywebsitex.com/xml/webservice"
              targetNamespace="http://www.mywebsitex.com/xml/webservice">


<wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:import namespace="http://www.mywebsitex.com/xml/webservice"                      
            schemaLocation="Request.xsd"/>
    </xsd:schema>

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:import namespace="http://www.mywebsitex.com/xml/webservice"                      
            schemaLocation="Response.xsd"/>
    </xsd:schema>

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:import namespace="http://www.mywebsitex.com/xml/webservice"                      
            schemaLocation="Error.xsd"/>
    </xsd:schema>
</wsdl:types>


<wsdl:message name="inferencerequest">                                                 
    <!-- <wsdl:part element="schema:inferencerequest" name="inferencerequest"/> -->               
</wsdl:message>
<wsdl:message name="inferenceresponse">                                                 
    <!-- <wsdl:part element="schema:inferenceresponse" name="inferenceresponse"/> -->               
</wsdl:message>
<wsdl:message name="errorresponse">                                                 
    <!-- <wsdl:part element="schema:errorresponse" name="errorresponse"/> -->               
</wsdl:message>

<wsdl:portType name="mtchWS">                                                 
    <wsdl:operation name="inference">
        <wsdl:input message="tns:inferencerequest" name="inferencerequest"/>
        <wsdl:output message="tns:inferenceresponse" name="inferenceresponse"/>
        <wsdl:fault message="tns:errorresponse" name="errorresponse"/>             
    </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="mtchWSBinding" type="tns:mtchWS">                  
    <soap:binding style="document"                                                   
        transport="http://schemas.xmlsoap.org/soap/http"/>                           
    <wsdl:operation name="inference">
        <soap:operation soapAction="http://www.mywebsitex.com/webservice"/>           
        <wsdl:input name="inferencerequest">
            <soap:body use="literal"/>                                               
        </wsdl:input>
        <wsdl:output name="inferenceresponse">
            <soap:body use="literal"/>
        </wsdl:output>
        <wsdl:fault name="errorreponse">
            <!-- <soap:fault use="literal"/>-->
        </wsdl:fault>
    </wsdl:operation>
</wsdl:binding>

<wsdl:service name="mtchWSService">
    <wsdl:port binding="tns:mtchWSBinding" name="mtchWSPort">          
        <soap:address location="http://localhost:8080/mwp/mws"/>             
    </wsdl:port>
</wsdl:service>                  

这就是我在 web.xml 中定义的方式:

<servlet>
    <servlet-name>mws</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
            <param-value>classpath:/resources/mtchwebservice/applicationContext-MtchWebService.xml</param-value>
    </init-param>

    <init-param>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>

    <load-on-startup>2</load-on-startup>
</servlet>

This problem still not solved since 3 days, really appreciated if someone can help, here is all the code below.

Problem is: this web service works well if I show the wsdl file (which is in my eclipse project directory) to the soapUI from hard disc. But it can not find the Request schema file if I give the url as:

http://localhost:8080/mwp/mws/mwsid.wsdl

This expose the wsdl correctly but cant find the schema, I get the error from soapUI:

ERROR:Failed to load url [http://localhost:8080/mwp/mws/Request.xsd]

this is the spring config file

<?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">

<description>
</description>

<bean id="webServicePluginDescriptor"
    class="com.mywebsite.ws.configuration.mtchWebservicePluginDescriptor" />

<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">

    <property name="schema"
        value="classpath:/wsdl/Request.xsd" />
    <property name="validateRequest" value="true" />
    <property name="validateResponse" value="false" />
</bean>

<bean id="PropertyResource" class="com.mywebsite.ws.im.PropertyResource">
    <property name="resource"
        value="/WEB-INF/client-specific/InferenceMachine.properties" />
</bean>

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

<bean id="messageWebService" class="com.mywebsite.ws.service.MessageWebService"
    scope="request">
    <aop:scoped-proxy />
    <property name="inferenceService" ref="inferenceService" />
</bean>

<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="classpath:/wsdl/Request.xsd" />
</bean>

<bean id="mwsid"
    class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
    <constructor-arg value="classpath:/wsdl/mtchwsdl.wsdl" />
</bean>

<bean id="inferenceService" class="com.mywebsite.ws.im.InferenceService"
    scope="request">
    <aop:scoped-proxy />
    <property name="webServiceConfiguration" ref="wsPlayerConfiguration" />

    <property name="properties">
        <bean class="com.mywebsite.ws.im.PropertyResource">
            <property name="resource"
                value="/WEB-INF/client-specific/InferenceMachine.properties" />
        </bean>
    </property>
</bean>

<!-- ~~~~~~~ Application beans ~~~~~~~ -->
<bean id="wsPlayerConfiguration"
    class="com.mywebsite.ws.configuration.WebServiceConfiguration"
    scope="request">
    <aop:scoped-proxy />
    <property name="playerConfiguration" ref="playerConfiguration"></property>
    <property name="configurationSetup" ref="configurationSetup"></property>
</bean>

this is the wsdl file:

 <?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.mywebsitex.com/xml/webservice"
              xmlns:tns="http://www.mywebsitex.com/xml/webservice"
              targetNamespace="http://www.mywebsitex.com/xml/webservice">


<wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:import namespace="http://www.mywebsitex.com/xml/webservice"                      
            schemaLocation="Request.xsd"/>
    </xsd:schema>

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:import namespace="http://www.mywebsitex.com/xml/webservice"                      
            schemaLocation="Response.xsd"/>
    </xsd:schema>

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:import namespace="http://www.mywebsitex.com/xml/webservice"                      
            schemaLocation="Error.xsd"/>
    </xsd:schema>
</wsdl:types>


<wsdl:message name="inferencerequest">                                                 
    <!-- <wsdl:part element="schema:inferencerequest" name="inferencerequest"/> -->               
</wsdl:message>
<wsdl:message name="inferenceresponse">                                                 
    <!-- <wsdl:part element="schema:inferenceresponse" name="inferenceresponse"/> -->               
</wsdl:message>
<wsdl:message name="errorresponse">                                                 
    <!-- <wsdl:part element="schema:errorresponse" name="errorresponse"/> -->               
</wsdl:message>

<wsdl:portType name="mtchWS">                                                 
    <wsdl:operation name="inference">
        <wsdl:input message="tns:inferencerequest" name="inferencerequest"/>
        <wsdl:output message="tns:inferenceresponse" name="inferenceresponse"/>
        <wsdl:fault message="tns:errorresponse" name="errorresponse"/>             
    </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="mtchWSBinding" type="tns:mtchWS">                  
    <soap:binding style="document"                                                   
        transport="http://schemas.xmlsoap.org/soap/http"/>                           
    <wsdl:operation name="inference">
        <soap:operation soapAction="http://www.mywebsitex.com/webservice"/>           
        <wsdl:input name="inferencerequest">
            <soap:body use="literal"/>                                               
        </wsdl:input>
        <wsdl:output name="inferenceresponse">
            <soap:body use="literal"/>
        </wsdl:output>
        <wsdl:fault name="errorreponse">
            <!-- <soap:fault use="literal"/>-->
        </wsdl:fault>
    </wsdl:operation>
</wsdl:binding>

<wsdl:service name="mtchWSService">
    <wsdl:port binding="tns:mtchWSBinding" name="mtchWSPort">          
        <soap:address location="http://localhost:8080/mwp/mws"/>             
    </wsdl:port>
</wsdl:service>                  

and this is how I define in the web.xml:

<servlet>
    <servlet-name>mws</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
            <param-value>classpath:/resources/mtchwebservice/applicationContext-MtchWebService.xml</param-value>
    </init-param>

    <init-param>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>

    <load-on-startup>2</load-on-startup>
</servlet>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿港巷口少年归 2024-11-22 18:34:04

将:更改

<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="classpath:/wsdl/Request.xsd" />
</bean>

为:

<bean id="Request" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="classpath:/wsdl/Request.xsd" />
</bean>

应该可以使 Request.xsd 的架构解析正常工作。 MessageDispatcherServlet 查找 XsdSchema 类型并根据 id/name 将对 xsd 的请求解析到架构。

Changing:

<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="classpath:/wsdl/Request.xsd" />
</bean>

to:

<bean id="Request" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="classpath:/wsdl/Request.xsd" />
</bean>

should get the schema resolution of Request.xsd to work. The MessageDispatcherServlet looks for XsdSchema types and resolves the request for a xsd to the schema based on the id/name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文