CXF wsdl2java 不生成参数值

CXF wsdl2java doesn't generate parameter value

我对 CXF 中的 wsdl2java 有疑问。它生成 java.lang.Object 参数而不是正确的 XACMLAuthzDecisionType。它抱怨:
操作 {urn:com:test:se:authz:AuthzService}Evaluate 无法展开,输入消息必须引用与操作具有相同本地名称的全局元素声明

我尝试更改输入参数的名称和相应的消息部分,但没有帮助。

生成的服务端界面如下:

@WebService(targetNamespace = "urn:com:test:se:authz:AuthzService", name = "AuthzServicePort")
@XmlSeeAlso({org.w3._2000._09.xmldsig_.ObjectFactory.class, oasis.names.tc.xacml._3_0.profile.saml2_0.v2.schema.assertion.wd_13.ObjectFactory.class, oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory.class, oasis.names.tc.saml._2_0.protocol.ObjectFactory.class, org.w3._2001._04.xmlenc_.ObjectFactory.class, oasis.names.tc.saml._2_0.assertion.ObjectFactory.class, oasis.names.tc.xacml._3_0.profile.saml2_0.v2.schema.protocol.wd_13.ObjectFactory.class})
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
public interface AuthzServicePort {

    @WebResult(name = "Response", targetNamespace = "urn:oasis:names:tc:SAML:2.0:protocol", partName = "parameters")
    @WebMethod(operationName = "Evaluate", action = "urn:com:test:se:authz:AuthzService:Evaluate")
    public oasis.names.tc.saml._2_0.protocol.ResponseType evaluate(
        @WebParam(partName = "parameters", name = "XACMLAuthzDecisionQuery", targetNamespace = "urn:oasis:names:tc:xacml:3.0:profile:saml2.0:v2:schema:protocol:wd-13")
        java.lang.Object parameters
    );
}


我在命令行中使用 CXF 3.1.2:

apache-cxf-3.1.2\bin\wsdl2java -d c:\temp\gensrc\AuthzServiceTest -server -validate=all -autoNameResolution -verbose -xjc-verbose AuthzServiceTest.wsdl

有谁知道为什么不能生成正确的参数?

Java class XACMLAuthzDecisionQueryType 获取 'You are getting this "catch-all" property because the field name "Extensions" is used by two different parts of a schema'

我不知道这是否会导致参数生成失败。

我使用的 WSDL:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions 
    xmlns="urn:com:test:se:authz:AuthzService"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:tns="urn:com:test:se:authz:AuthzService" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xacml="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"
    xmlns:xacml-samlp="urn:oasis:names:tc:xacml:3.0:profile:saml2.0:v2:schema:protocol:wd-13"
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
    name="AuthzService" 
    targetNamespace="urn:com:test:se:authz:AuthzService"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    >

    <wsdl:types>
        <xsd:schema>
            <xsd:import namespace="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" 
                        schemaLocation="http://docs.oasis-open.org/xacml/3.0/xacml-core-v3-schema-wd-17.xsd"/>

            <xsd:import namespace="urn:oasis:names:tc:xacml:3.0:profile:saml2.0:v2:schema:protocol:wd-13" 
                        schemaLocation="http://docs.oasis-open.org/xacml/3.0/xacml-3.0-profile-saml2.0-v2-schema-protocol-wd-13.xsd"/>

            <xsd:import namespace="urn:oasis:names:tc:SAML:2.0:protocol" 
                        schemaLocation="http://docs.oasis-open.org/security/saml/v2.0/saml-schema-protocol-2.0.xsd"/>
        </xsd:schema>
    </wsdl:types>

  <wsdl:message name="Evaluate">
    <wsdl:part name="parameters" element="xacml-samlp:XACMLAuthzDecisionQuery"/>
  </wsdl:message>

  <wsdl:message name="EvaluateResponse">
    <wsdl:part name="parameters" element="samlp:Response"/>
  </wsdl:message>

  <wsdl:portType name="AuthzServicePort">
    <wsdl:operation name="Evaluate">
      <wsdl:input message="tns:Evaluate"/>
      <wsdl:output message="tns:EvaluateResponse"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="AuthzServiceSOAPBinding" type="tns:AuthzServicePort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="Evaluate">
      <soap:operation soapAction="urn:com:test:se:authz:AuthzService:Evaluate" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="AuthzService">
    <wsdl:port name="AuthzService" binding="tns:AuthzServiceSOAPBinding" >
        <soap:address location="http://localhost:8080/AuthzService/"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

我终于找到了解决这个问题的方法。 OASIS 发布了解决此问题的新工作草案 (wd-14)。 可以在这里找到: http://docs.oasis-open.org/xacml/xacml-saml-profile/v2.0/cs02/schemas/xacml-3.0-profile-saml2.0-v2-schema-protocol-wd-14.xsd.

您需要下载 xsd 文件并将断言 xsd 的导入架构语句更改为:

<import namespace="urn:oasis:names:tc:xacml:3.0:profile:saml2.0:v2:schema:assertion:wd-14"
        schemaLocation="http://docs.oasis-open.org/xacml/xacml-saml-profile/v2.0/cs02/schemas/xacml-3.0-profile-saml2.0-v2-schema-assertion-wd-14.xsd" />

您需要使用绑定文件来避免定义两个扩展元素的问题。

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    version="2.1">
    <jxb:bindings schemaLocation="xacml-3.0-profile-saml2.0-v2-schema-protocol-wd-14.xsd">
            <jxb:bindings node="//xs:complexType[@name='XACMLAuthzDecisionQueryType']//xs:element[@ref='xacml-samlp:Extensions']">
                <jxb:property name="ExtensionList"/>
            </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>