Search in sources :

Example 1 with GetSessionInfoResponse

use of com.jasperwireless.api.ws.service.GetSessionInfoResponse in project open-smart-grid-platform by OSGP.

the class JasperWirelessTerminalClient method getSession.

public GetSessionInfoResponse getSession(final String iccid) {
    final GetSessionInfoRequest getSessionInfoRequest = WS_CLIENT_FACTORY.createGetSessionInfoRequest();
    getSessionInfoRequest.setLicenseKey(this.jasperWirelessTerminalAccess.getLicenseKey());
    getSessionInfoRequest.setMessageId(this.correlationIdProviderService.getCorrelationId("messageID", iccid));
    getSessionInfoRequest.setVersion(this.jasperWirelessTerminalAccess.getApiVersion());
    getSessionInfoRequest.getIccid().add(iccid);
    for (final ClientInterceptor interceptor : this.jasperWebServiceTemplate.getInterceptors()) {
        if (interceptor instanceof Wss4jSecurityInterceptor) {
            setUsernameToken((Wss4jSecurityInterceptor) interceptor, this.jasperWirelessTerminalAccess.getUsername(), this.jasperWirelessTerminalAccess.getPassword());
        }
    }
    // override default uri
    this.jasperWebServiceTemplate.setDefaultUri(this.jasperWirelessTerminalAccess.getUri());
    return (GetSessionInfoResponse) this.jasperWebServiceTemplate.marshalSendAndReceive(getSessionInfoRequest, new SoapActionCallback(SERVICE_SESSION_INFO));
}
Also used : Wss4jSecurityInterceptor(org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor) GetSessionInfoRequest(com.jasperwireless.api.ws.service.GetSessionInfoRequest) SoapActionCallback(org.springframework.ws.soap.client.core.SoapActionCallback) GetSessionInfoResponse(com.jasperwireless.api.ws.service.GetSessionInfoResponse) ClientInterceptor(org.springframework.ws.client.support.interceptor.ClientInterceptor)

Example 2 with GetSessionInfoResponse

use of com.jasperwireless.api.ws.service.GetSessionInfoResponse in project open-smart-grid-platform by OSGP.

the class SessionProviderKpn method getIpAddress.

@Override
public String getIpAddress(final String iccId) throws OsgpException {
    GetSessionInfoResponse response;
    try {
        response = this.jasperWirelessTerminalClient.getSession(iccId);
    } catch (final SoapFaultClientException e) {
        final String errorMessage = String.format("iccId %s is probably not supported in this session provider", iccId);
        LOGGER.error(errorMessage, e);
        throw new FunctionalException(FunctionalExceptionType.INVALID_ICCID, ComponentType.PROTOCOL_DLMS, new OsgpException(ComponentType.PROTOCOL_DLMS, e.getMessage()));
    }
    final SessionInfoType sessionInfoType = this.getSessionInfo(response);
    if (sessionInfoType == null) {
        return null;
    }
    return sessionInfoType.getIpAddress();
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) GetSessionInfoResponse(com.jasperwireless.api.ws.service.GetSessionInfoResponse) SoapFaultClientException(org.springframework.ws.soap.client.SoapFaultClientException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) SessionInfoType(com.jasperwireless.api.ws.service.SessionInfoType)

Aggregations

GetSessionInfoResponse (com.jasperwireless.api.ws.service.GetSessionInfoResponse)2 GetSessionInfoRequest (com.jasperwireless.api.ws.service.GetSessionInfoRequest)1 SessionInfoType (com.jasperwireless.api.ws.service.SessionInfoType)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 ClientInterceptor (org.springframework.ws.client.support.interceptor.ClientInterceptor)1 SoapFaultClientException (org.springframework.ws.soap.client.SoapFaultClientException)1 SoapActionCallback (org.springframework.ws.soap.client.core.SoapActionCallback)1 Wss4jSecurityInterceptor (org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor)1