2010-10-14 118 views
4

我正在嘗試製作一個非常簡單的web服務,並且在使spring生成正確的wsdl時遇到一些困難。我已盡我所能從spring tutorial複製示例。如果任何人有關於我在做什麼錯誤的線索,我會非常感謝幫助。Spring-WS WSDL生成問題

本質上,有一個名爲IncidentHeaderEndpoint的EndPoint(目前沒有功能)。我想調用客戶端發送形式的XML請求:

<browseIncidents> 
    <responsibleManager>foo</responsibleManager> 
</browseIncidents> 

我的終結點是這樣的:

public class IncidentHeaderEndpoint extends AbstractJDomPayloadEndpoint { 
    XPath respMgrExpression; 

    public IncidentHeaderEndpoint() { 
     Namespace namespace = Namespace.getNamespace("trust-service", "http://act-informatics.co.uk/trust-service/schemas"); 
     try { 
      respMgrExpression = XPath.newInstance("//trust-service:StartDate"); 
      respMgrExpression.addNamespace(namespace); 
     } catch (JDOMException e) { 
      e.printStackTrace(); 
     } 
    } 
    protected Element invokeInternal(Element request) throws Exception { 
     String respMgr = respMgrExpression.valueOf(request); 
     return null; 
    } 
} 

當我在Tomcat中,我得到以下警告部署:

14-Oct-2010 13:08:43 org.springframework.ws.wsdl.wsdl11.provider.DefaultMessagesProvider addMessages 
WARNING: No messages were created, make sure the referenced schema(s) contain elements 
14-Oct-2010 13:08:43 org.springframework.ws.wsdl.wsdl11.provider.AbstractPortTypesProvider createOperations 
WARNING: No operations were created, make sure the WSDL contains messages 

這是我的彈簧配置:

<!-- TRUST WEB SERVICES --> 
<bean id="incidentHeaderEndpoint" class="co.uk.act.cics.ws.IncidentHeaderEndpoint" /> 

<!-- Routing Mapping --> 
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping"> 
    <property name="mappings"> 
     <props> 
      <prop key="{http://act-informatics.co.uk/trust-service/schemas}BrowseIncidents">incidentHeaderEndpoint</prop> 
     </props> 
    </property> 
    <property name="interceptors"> 
     <bean 
      class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" /> 
    </property> 
</bean> 

<!-- WSDL Generation --> 
<bean id="browse" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"> 
    <property name="schema" ref="trust-schema" /> 
    <property name="portTypeName" value="TrustService" /> 
    <property name="locationUri" value="http://localhost:8080/trust-service/browseIncidents/" /> 
    <property name="targetNamespace" value="http://act-informatics.co.uk/trust-service/definitions"/> 
</bean> 

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

這是我的架構 - WEB-INF /信任service.xsd:

<?xml version="1.0" encoding="UTF-8"?>` 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://act-informatics.co.uk/trust-service/schemas" xmlns:schemas="http://act-informatics.co.uk/trust-service/schemas"> 
    <xs:element name="browseIncidents"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="responsibleManager" type="xs:string"/> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

,這是位於http://localhost:8080/trust-service/browseIncidents/browse.wsdl有問題的WSDL:

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions xmlns:sch="http://act-informatics.co.uk/trust-service/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://act-informatics.co.uk/trust-service/definitions" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://act-informatics.co.uk/trust-service/definitions"> 
    <wsdl:types> 
    <xs:schema xmlns:schemas="http://act-informatics.co.uk/trust-service/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://act-informatics.co.uk/trust-service/schemas"> 
    <xs:element name="browseIncidents"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="responsibleManager" type="xs:string"/> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 
    </wsdl:types> 
    <wsdl:portType name="TrustService"> 
    </wsdl:portType> 
    <wsdl:binding name="TrustServiceSoap11" type="tns:TrustService"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    </wsdl:binding> 
    <wsdl:service name="TrustServiceService"> 
    <wsdl:port binding="tns:TrustServiceSoap11" name="TrustServiceSoap11"> 
     <soap:address location="http://localhost:8080/trust-service/browseIncidents/"/> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

回答

12

在你的XSD的輸入和輸出元素的名稱應該具有請求和響應的後綴。那麼只有spring-ws會將其識別爲輸入和輸出參數。

,如果你有元素OrderRequest和OrderResponse,與名稱訂單的操作將得到與輸入和輸出OrderRequest和OrderResponse創建

+1

感謝這個工作,但我錯過了something.I沒有看到任何相關文檔。 – 2015-08-07 09:11:05

+0

謝謝!有用! – 2016-12-23 10:34:28