我目前正在尝试理解我已经获得的WSDL文件以及为什么CXF(使用CXF-2.7.17)不会为此服务生成符合JAX-WS的类。以下是WSDL文件的摘录:
<wsdl:portType name="ServiceSoap">
<wsdl:operation name="GetClient">
<wsdl:input message="tns:GetClientSoapIn" />
<wsdl:output message="tns:GetClientSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="ServiceHttpPost">
<wsdl:operation name="GetClient">
<wsdl:input message="tns:GetClientHttpPostIn" />
<wsdl:output message="tns:GetClientHttpPostOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetClient">
<soap:operation soapAction="http://ws.comp.com/GetClient" style="document" />
<wsdl:input>
<soap:body use="literal" />
<soap:header message="tns:GetClientCreds" part="Creds" use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:binding name="ServiceHttpPost" type="tns:ServiceHttpPost">
<http:binding verb="POST" />
<wsdl:operation name="GetClient">
<http:operation location="/GetClient" />
<wsdl:input>
<mime:content type="application/x-www-form-urlencoded" />
</wsdl:input>
<wsdl:output>
<mime:mimeXml part="Body" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
要点是,我有一个WSDL文件,其中包含更多我的SOAP绑定,我希望CXF变成一个实际的服务。
在此WSDL文件上使用WSDL2Java
,我得到以下stacktrace:
line 3168 column 66 of file:/home/user/test/Service.wsdl: cvc-complex-type.4: Attribute 'part' must appear on element 'mime:content'.
at org.apache.cxf.tools.validator.internal.SchemaValidator.validate(SchemaValidator.java:203)
at org.apache.cxf.tools.validator.internal.SchemaValidator.validate(SchemaValidator.java:119)
at org.apache.cxf.tools.validator.internal.SchemaValidator.isValid(SchemaValidator.java:103)
at org.apache.cxf.tools.validator.internal.WSDL11Validator.isValid(WSDL11Validator.java:157)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.validate(JAXWSDefinitionBuilder.java:206)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:204)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:164)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:412)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
[...]
抱怨该行
<mime:content type="application/x-www-form-urlencoded" />
显然来自符合cxf's built-in xsd的WS-I attachment profile,需要part
才能出现(与WSDL-1.1规范相反)。
因此我的问题是:
我可以让验证器忽略这些绑定吗?