How to call dss soap api in java with credentials header in soap header?

Hi, here's some context before I start to ask my question

Java version: 17

Gradle version: 8.0

Plugin used to generate stub: https://github.com/yupzip/wsdl2java

WSDL file I am referring to: https://selectapi.datascope.refinitiv.com/DataScopeApi/v1/ExtractionService.asmx?WSDL


Currently I am trying to call ValidateInstruments soap api, and I believe I have to provide the credential in the soap header but I don't know where can I set the credential header, below are the ValidateInstruments web method generated by the wsdl2java plugin

1687247149391.png


The InstrumentValidationRequest object:

1687247205124.png


Please help me with this, thanks in advance.

Best Answer

  • Jirapongse
    Answer ✓

    @kks102613

    I can use Apache CFX 2.X to generate classes for DSS SOAPI API.

    1687313466835.png

    It uses WSDL2Java to generate Java classes. I need to check "Enable processing of implicit SOAP headers" (-exsh true).

    1687313505221.png

    However, I need to modify the OperationInfoHeader.Duration property in OperationInfoHeader.java to String.

    public class OperationInfoHeader {


        @XmlElement(name = "Host")
        protected String host;
        @XmlElement(name = "EjvServer")
        protected String ejvServer;
        @XmlElement(name = "ProcessingTime", required = true)
        protected String processingTime;
        @XmlAnyAttribute
        private Map<QName, String> otherAttributes = new HashMap<QName, String>();
    ...
    ...
        public String getProcessingTime() {
            return processingTime;
    }



        /**
         * Sets the value of the processingTime property.
         * 
         * @param value
         *     allowed object is
         *     {@link Duration }
         *     
         */
        public void setProcessingTime(Duration value) {
            this.processingTime = "";
    }

    ..
    }

    The example code is in the ExtractionService_ExtractionService_Client.java file. It looks like this:

            ExtractionService_Service ss = new ExtractionService_Service(wsdlURL, SERVICE_NAME);
            ExtractionService port = ss.getExtractionService();


            {
            System.out.println("Invoking getGovCorpCurrencyTypes...");
            com.datascope.select.extractionservice.v1.CredentialsHeader _getGovCorpCurrencyTypes_credentialsHeaderVal = new com.datascope.select.extractionservice.v1.CredentialsHeader();
            _getGovCorpCurrencyTypes_credentialsHeaderVal.setUsername("DSS User");
    _getGovCorpCurrencyTypes_credentialsHeaderVal.setPassword("DSS Password");

            _getGovCorpCurrencyTypes_credentialsHeaderVal.setAuthenticationToken("");
            jakarta.xml.ws.Holder<com.datascope.select.extractionservice.v1.CredentialsHeader> _getGovCorpCurrencyTypes_credentialsHeader = new jakarta.xml.ws.Holder<com.datascope.select.extractionservice.v1.CredentialsHeader>(_getGovCorpCurrencyTypes_credentialsHeaderVal);
            com.datascope.select.extractionservice.v1.EjvServerHeader _getGovCorpCurrencyTypes_ejvServerHeader = new com.datascope.select.extractionservice.v1.EjvServerHeader();
            _getGovCorpCurrencyTypes_ejvServerHeader.setServer("Server-33758018");
            jakarta.xml.ws.Holder<com.datascope.select.extractionservice.v1.OperationInfoHeader> _getGovCorpCurrencyTypes_operationInfoHeader = new jakarta.xml.ws.Holder<com.datascope.select.extractionservice.v1.OperationInfoHeader>();
            com.datascope.select.extractionservice.v1.ArrayOfValueInfo _getGovCorpCurrencyTypes__return = port.getGovCorpCurrencyTypes(_getGovCorpCurrencyTypes_credentialsHeader, _getGovCorpCurrencyTypes_ejvServerHeader, _getGovCorpCurrencyTypes_operationInfoHeader);
            System.out.println("getGovCorpCurrencyTypes.result=" + _getGovCorpCurrencyTypes__return);


            System.out.println("getGovCorpCurrencyTypes._getGovCorpCurrencyTypes_credentialsHeader=" + _getGovCorpCurrencyTypes_credentialsHeader.value);
            System.out.println("getGovCorpCurrencyTypes._getGovCorpCurrencyTypes_operationInfoHeader=" + _getGovCorpCurrencyTypes_operationInfoHeader.value);


            }


Answers