CXF wsdl2java不生成参数值

时间:2015-09-21 12:29:22

标签: cxf wsdl2java

我在CXF中遇到wsdl2java的问题。它生成一个java.lang.Object参数,而不是正确的XACMLAuthzDecisionType。它抱怨:
Operation {urn:com:test:se:authz:AuthzService}无法解包评估,输入消息必须引用具有与操作相同的本地名称的全局元素声明

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

生成的服务器界面如​​下:

@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类XACMLAuthzDecisionQueryType获取'您正在获取此“catch-all”属性,因为字段名称“Extensions”由架构的两个不同部分“使用。

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

我使用的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>

1 个答案:

答案 0 :(得分:1)

我终于找到了解决这个问题的方法。 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 schema语句更改为:

<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" />

您需要使用绑定文件来避免两个已定义的Extension元素出现问题。

<?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>