package ee.cybernetica.uxp.securityserverloadtesting.service.test;

import ee.cybernetica.uxp.securityserverloadtesting.service.types.SendBinaryRequest;
import ee.cybernetica.uxp.securityserverloadtesting.service.types.SendBinaryResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.server.endpoint.annotation.SoapHeader;


@Endpoint
public class SendBinaryEndpoint {
    private static final String NAMESPACE_URI = "http://cybernetica.ee/uxp/securityserverloadtesting/service/types";


    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "sendBinaryRequest")
    @ResponsePayload
    public SendBinaryResponse respondAttachmentLength(
            @RequestPayload SendBinaryRequest request,
            @SoapHeader("{http://x-road.ee/xsd/x-road.xsd}hdrstd")SoapHeaderElement soapHeaderElement
            ) {
        SendBinaryResponse response = new SendBinaryResponse();
        try {
            response.setSize(request.getBinaryData().length);
        } catch (Exception ignored) {

        }


        return response;
    }
}
