1

我在 WSDL 文件中有以下内容:

<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
         xmlns:tns="urn:zimbraAdmin"
         xmlns:zns="urn:zimbra"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
         xmlns:si="http://soapinterop.org/xsd"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
         xmlns="http://schemas.xmlsoap.org/wsdl/"
         targetNamespace="urn:zimbraAdmin">

    <element name="AuthResponse">
        <complexType>
            <sequence>
                <element name="authToken" type="xsd:string"  />
                <element name="lifetime" type="xsd:string"/>
                <element ref="tns:a" maxOccurs="unbounded"/>
            </sequence>
        </complexType>
    </element>

<message name="AuthResponse">
    <part name="AuthResponse" element="tns:AuthResponse"/>
</message>

<operation name="AuthRequest">
    <input message="tns:AuthRequest"/>
    <output message="tns:AuthResponse"/>
</operation>

但是,当发送以下请求时:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
    <ns2:AuthRequest xmlns:ns2="urn:zimbraAdmin" xmlns:ns3="urn:zimbra">
        <name>admin</name>
        <password>password</password>
    </ns2:AuthRequest>
</S:Body>
</S:Envelope>

以下内容返回:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
        <context xmlns="urn:zimbra">
            <change token="2099" />
        </context>
    </soap:Header>
    <soap:Body>
        <AuthResponse xmlns="urn:zimbraAdmin">
            <authToken>0_c728cf3ae4049ecb8fa5eb19f19397e4661e53a2_69643d33363a38373861353736372d356630632d343266352d623466372d6166666163383064326133643b6578703d31333a313337343533383131303638333b61646d696e3d313a313b747970653d363a7a696d6272613b</authToken>
            <lifetime>43199997</lifetime>
            <a n="zimbraIsDomainAdminAccount">false</a>
        </AuthResponse>
    </soap:Body>
</soap:Envelope>

我遇到的问题是未分配 authToken 和生命周期(即它们返回 null)为 AuthResponse 生成的代码(使用 cxf 2.7.5 wsdl2java 生成)如下所示:

@XmlRootElement(name = "AuthResponse")
public class AuthResponse {

    @XmlElement(required = true)
    protected String authToken;
    @XmlElement(required = true)
    protected String lifetime;
    @XmlElement(namespace = "urn:zimbraAdmin", required = true)
    protected List<A> a;

我相信,如果它如下所示,我的问题将得到解决:

@XmlRootElement(name = "AuthResponse")
public class AuthResponse {
    @XmlElement(namespace = "urn:zimbraAdmin",required = true)
    protected String authToken;
    @XmlElement(namespace = "urn:zimbraAdmin",required = true)
    protected String lifetime;
    @XmlElement(namespace = "urn:zimbraAdmin", required = true)
    protected List<A> a;

问题是,我需要在 WSDL 文件中进行哪些更改才能为客户端生成正确的代码?

编辑

作为参考,我正在使用http://blog.jeshurun.ca/wp-content/uploads/2011/12/zimbra.wsdl提供的 zimbra.wsdl

4

0 回答 0