【发布时间】:2021-09-13 09:37:00
【问题描述】:
wsdl 是自上而下实现的。 Java 类是使用cxf-codegen-plugin 生成的。
它有一个简单的类型定义为
<xsd:simpleType name="DescriptionType">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="512" />
<xsd:minLength value="1"/>
<xsd:whiteSpace value="collapse"/>
</xsd:restriction>
</xsd:simpleType>
我尝试将" description" 放入请求中,但它没有修剪空间。 “折叠”选项应该这样做。
这是 wsdl:
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="foo"
xmlns="http://xmlns.ec.eu/DataService/foo/V2.2"
targetNamespace="http://xmlns.ec.eu/DataService/foo/V2.2"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/"
>
<wsdl:import namespace="http://xmlns.ec.eu/DataService/foo/V2.2"
location="fooAbstract.wsdl">
</wsdl:import>
<wsdl:binding name="fooSoapBinding" type="foo">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Insert">
<soap:operation soapAction="urn:foo1Insert" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ServiceFault">
<soap:fault name="ServiceFault" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="foo">
<wsdl:port name="foo" binding="fooSoapBinding">
<soap:address location="http://xmlns.ec.eu/DataService/foo/V2" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
这是服务实现:
@Stateless
@WebService(portName = "foo",
serviceName = "foo",
targetNamespace = "http://xmlns.ec.eu/DataService/foo/V2.2",
wsdlLocation = "/META-INF/resources/wsdl/DataService/foo/V2.2/fooConcrete.wsdl",
endpointInterface = "foo.package")
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
@SchemaValidation(inbound = true, outbound = false, handler = SchemaValidationHandler.class)
@HandlerChain(file = "../../../../../../../META-INF/handler-chain.xml")
@DeclareRoles({READ_ROLE, WRITE_ROLE})
public class FooService implements Foo {
【问题讨论】:
-
@RobbyCornelissen 真的吗?我虽然他们被删除,因为它在这里解释w3schools.com/XML/schema_facets.asp
The whiteSpace constraint is set to "collapse", which means that the XML processor WILL REMOVE all white space characters -
看来你是完全正确的。我会删除我的评论。
-
DescriptionType的字段生成的代码是什么样的?它们是纯字符串还是其他类型?字段上的注释是什么? -
@Bogdan 是的,一个字符串。
@XmlElement(required = true) protected String description; -
我会期待更多的注释,像这样:stackoverflow.com/questions/359315/…