java之Spring Web 服务动态 wsdl 不为架构元素生成消息

txw1958 阅读:14 2024-06-03 14:00:57 评论:0

我有以下架构:

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

我已经浏览了架构文件一百万次,但看不出生成的消息和未生成的消息之间有任何区别。你能看出他们为什么不是吗?

请您参考如下方法:

是因为名字。 Spring 使用消息调用的约定 SomethingRequest和回复 SomethingResponse .


标签:java
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号