Spring的web服务的动态WSDL不是架构元素生成的消息(Spring web service

2019-09-19 11:42发布

我有以下模式:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:m="http://ws.mypackage.com" 
xmlns:xmime="http://www.w3.org/2005/05/xmlmime" elementFormDefault="qualified"
targetNamespace="http://ws.mypackage.com" 
attributeFormDefault="unqualified"> 

    <xs:element name="downloadMessageRequestSaaj">
        <xs:complexType/>
    </xs:element>

    <xs:element name="downloadMessageRequest">
        <xs:complexType/>
    </xs:element>   

    <xs:element name="downloadMessageResponseSaaj" type="m:downloadResponseSaajType" />

    <xs:complexType name="downloadResponseSaajType">
            <xs:sequence>
                <xs:element name="requestName" type="xs:string"/>
                <xs:element name="payLoad">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="messagePayLoad" type="xs:base64Binary" xmime:expectedContentTypes="multipart/related"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
     </xs:complexType>

    <xs:element name="downloadMessageResponse" type="m:downloadResponseType" />

    <xs:complexType name="downloadResponseType">
            <xs:sequence>
                <xs:element name="requestName" type="xs:string"/>
                <xs:element name="payLoad">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="messagePayLoad" type="xs:base64Binary" xmime:expectedContentTypes="multipart/related"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
     </xs:complexType>


     <xs:element name="localDTMRequest">
        <xs:complexType/>
    </xs:element>

    <xs:element name="localDTMResponse">
        <xs:complexType>        
            <xs:sequence>
                <xs:element name="localDTM" type="xs:dateTime"/>
            </xs:sequence>          
        </xs:complexType>
    </xs:element>    

</xs:schema>

并配置Spring来自动生成WSDL文件,如下图所示:

<ws:dynamic-wsdl id="serviceDefinition" portTypeName="myService"
        locationUri="http://localhost:8080/springWsTest/webservice">
        <ws:xsd location="/WEB-INF/schemas/schema.xsd" />
    </ws:dynamic-wsdl>

生成的WSDL文件缺少downloadMessageRequestSaaj和downloadMessageResponseSaaj的“消息”。 这是为什么?

下面是生成的WSDL文件..

<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://ws.mypackage.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.mypackage.com" targetNamespace="http://ws.mypackage.com">
  <wsdl:types>
    <xs:schema xmlns:m="http://ws.mypackage.com" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ws.mypackage.com">   

    <xs:element name="downloadMessageRequestSaaj">
        <xs:complexType/>
    </xs:element>

    <xs:element name="downloadMessageRequest">
        <xs:complexType/>
    </xs:element>   

    <xs:element name="downloadMessageResponseSaaj" type="m:downloadResponseSaajType"/>

    <xs:complexType name="downloadResponseSaajType">
            <xs:sequence>
                <xs:element name="requestName" type="xs:string"/>
                <xs:element name="payLoad">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="messagePayLoad" type="xs:base64Binary" xmime:expectedContentTypes="multipart/related"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
     </xs:complexType>

    <xs:element name="downloadMessageResponse" type="m:downloadResponseType"/>

    <xs:complexType name="downloadResponseType">
            <xs:sequence>
                <xs:element name="requestName" type="xs:string"/>
                <xs:element name="payLoad">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="messagePayLoad" type="xs:base64Binary" xmime:expectedContentTypes="multipart/related"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
     </xs:complexType>


     <xs:element name="localDTMRequest">
        <xs:complexType/>
    </xs:element>

    <xs:element name="localDTMResponse">
        <xs:complexType>        
            <xs:sequence>
                <xs:element name="localDTM" type="xs:dateTime"/>
            </xs:sequence>          
        </xs:complexType>
    </xs:element>    

</xs:schema>
  </wsdl:types>
  <wsdl:message name="localDTMRequest">
    <wsdl:part element="tns:localDTMRequest" name="localDTMRequest">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="localDTMResponse">
    <wsdl:part element="tns:localDTMResponse" name="localDTMResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="downloadMessageRequest">
    <wsdl:part element="tns:downloadMessageRequest" name="downloadMessageRequest">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="downloadMessageResponse">
    <wsdl:part element="tns:downloadMessageResponse" name="downloadMessageResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="myService">
    <wsdl:operation name="localDTM">
      <wsdl:input message="tns:localDTMRequest" name="localDTMRequest">
    </wsdl:input>
      <wsdl:output message="tns:localDTMResponse" name="localDTMResponse">
    </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="downloadMessage">
      <wsdl:input message="tns:downloadMessageRequest" name="downloadMessageRequest">
    </wsdl:input>
      <wsdl:output message="tns:downloadMessageResponse" name="downloadMessageResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="myServiceSoap11" type="tns:myService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="localDTM">
      <soap:operation soapAction=""/>
      <wsdl:input name="localDTMRequest">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="localDTMResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="downloadMessage">
      <soap:operation soapAction=""/>
      <wsdl:input name="downloadMessageRequest">
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output name="downloadMessageResponse">
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="myServiceService">
    <wsdl:port binding="tns:myServiceSoap11" name="myServiceSoap11">
      <soap:address location="http://localhost:8080/springWsTest/webservice"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

我已经通过架构文件走了一万次,就不能看到所生成的消息和那些没有任何区别。 你可以看到为什么他们都没有?

Answer 1:

这是因为这个名字。 春天是使用消息称为公约SomethingRequest和响应SomethingResponse



文章来源: Spring web service dynamic wsdl not generating message for a schema element