AEM使用SOAP服务|得到正确的XML作为响应,但对象未绑定正确的值

时间:2018-07-04 13:40:13

标签: java soap aem

我正在尝试在AEM中使用SOAP Web服务。 这是wsdl

的链接

我使用 wsimport

生成了Java源文件

在AEM服务中,我正在以这种激活方法初始化服务客户端-

@Activate
    protected void activate(final Map<String, Object> props) {
        this.pstExternalServiceClient = new PSTExternalPortalService();
        this.pstExternalServiceClient.setHandlerResolver(new HandlerResolver() {

            @Override
            public List getHandlerChain(PortInfo portInfo) {
                ArrayList<SoapLogginghandler> handlerChain = new ArrayList<SoapLogginghandler>();
                // handlerChain.add(new SoapLogginghandler());
                return handlerChain;
            }
        });
    }

现在从Web服务获取数据的代码是-

@Override
    public AuthenticationToken authenticateByEmail(String email, String password) {
        LOGGER.info("email : {}, password : {}", email, password);
        if (pstExternalServiceClient != null) {
            PSTExternalPortalServiceSoap proxy = pstExternalServiceClient.getPSTExternalPortalServiceSoap();
            if (proxy != null) {
                AuthenticationToken token = proxy.getAuthenticationTokenWithEmail(sourceId, email, password, culture);
                LOGGER.info("token - validity : {}, message : {}", token.isIsValid(), token.getValidationMessage());
                return token;
            } else {
                LOGGER.warn("Proxy is null");
            }
        } else {
            LOGGER.warn("WebService client is not initialized");
        }
        return null;
    }

如果您将生成源Java文件,您将看到Authentication token具有2个字段-

  1. @XmlElement(name =“ IsValid”)受保护的布尔值isValid;
  2. @XmlElement(name =“ ValidationMessage”)受保护的字符串validateMessage;

对于isValid字段,我得到了错误;对于消息字段,我得到了null。但是,当我编写我的肥皂处理程序并记录响应时,这就是我得到的响应-

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header/>
    <soap:Body xmlns="https://www.mycoagresults.com/pstexternalportalservice/">
        <GetAuthenticationTokenWithEmailResponse>
            <GetAuthenticationTokenWithEmailResult>
                <IsValid>true</IsValid>
                <ValidationMessage/>
            </GetAuthenticationTokenWithEmailResult>
        </GetAuthenticationTokenWithEmailResponse>
    </soap:Body>
</soap:Envelope>

因此很明显,我在SOAP响应中获得了预期的真实价值,但是看起来像在解组响应时的某个地方。该值未正确设置,我无法弄清楚为什么?

作为参考,我正在关注此tutorial

请帮助我。预先感谢。

0 个答案:

没有答案