Spring-ws:如何从没有“请求”的xsd创建Wsdl元件 [英] Spring-ws: How to create Wsdl from an xsd with no "Request" element
问题描述
尝试为客户端实现SOAP Web服务,我需要一个wsdl文件来通过soapUI测试服务。但正如您在下面看到的,此xsd没有Request和Response方法,所有请求和响应都定义为基本ServiceProvider元素中的类型。因此,当我尝试通过spring-ws自动生成我的wsdl文件时,它不会生成正确的wsdl,因为Spring-ws要求所有请求和响应元素名称应以RequestResponse结束。
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".
我该怎么办?
<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>
....
这就是我如何生成wsdl文件
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>
推荐答案
没有这样的要求那些只是默认值。 此处在Spring-WS参考指南中。它还解释了要设置为覆盖这些默认值的属性。
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.
默认请求后缀为
请求
;默认响应后缀为响应
,但可以通过设置requestSuffix
来更改分别在< dynamic-wsdl />
上的responseSuffix
属性。
The default request suffix is
Request
; the default response suffix isResponse
, though these can be changed by setting therequestSuffix
andresponseSuffix
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>
这篇关于Spring-ws:如何从没有“请求”的xsd创建Wsdl元件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!