Spring-ws: How to create Wsdl from an xsd with no “Request” element

北城余情 提交于 2019-12-02 08:49:45

问题


Trying to implement a SOAP Webservice for a client and I need a wsdl file to test the service by soapUI. But as you can see below, this xsd has no Request and Response methods, all requests and responses are defined as a a "type" in a base ServiceProvider element. So when I try to auto generate my wsdl file by spring-ws it does not generate a proper wsdl, because Spring-ws requires all requests and responses element names should end with "Request" "Response".

What can I do?

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified" 
      attributeFormDefault="unqualified" targetNamespace="http://myurl" xmlns="http://myurl">

 <xs:element name="ServiceProviderT" nillable="false">
    <xs:annotation>
        <xs:documentation>ServiceProviderT is the message spec for data sent between TechX and service providers or
            vendors</xs:documentation>
                </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Version" type="xs:string" nillable="false"/>
                            <xs:choice>
                                <xs:element name="Request" type="RequestType" nillable="false"/>
                                <xs:element name="Response" type="ResponseType" nillable="false"/>
                                </xs:choice>
                                    </xs:sequence>
                                        </xs:complexType>
                                            </xs:element> 
                                                 ....

And this how I generate wsdl file

<sws:dynamic-wsdl id="myservice"
    portTypeName="MyService"
    locationUri="/myService"
    targetNamespace="http://myurl">
    <sws:xsd location="/schemas/my.xsd"/>
</sws:dynamic-wsdl>

回答1:


There is no such requirement those are just the defaults. This is explained here in the Spring-WS reference guide. It also explains which properties to set to override those defaults.

The default request suffix is Request; the default response suffix is Response, though these can be changed by setting the requestSuffix and responseSuffix attributes on <dynamic-wsdl />, respectively.

<sws:dynamic-wsdl id="myservice"
    portTypeName="MyService"
    locationUri="/myService"
    requestSuffix="YourRequestSuffixHere"
    responseSuffix="YourResponseSuffixHere"
    targetNamespace="http://myurl">
    <sws:xsd location="/schemas/my.xsd"/>
</sws:dynamic-wsdl>


来源:https://stackoverflow.com/questions/30620762/spring-ws-how-to-create-wsdl-from-an-xsd-with-no-request-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!