1

I would like to make a CreateShipmentOrderRequest call, unfortunately I always get back a response "login failed".

I think the authentication that is specified within the XML header is missing:

        <soapenv:Header>
            <cis:Authentification>
                <cis:user>2222222222_01</cis:user>
                <cis:signature>pass</cis:signature>
            </cis:Authentification>
        </soapenv:Header>

Call:

        GVAPI20De service = new GVAPI20De();
        GKV3XAPIServicePortType port = service.getGKVAPISOAP11Port0();
        
        Map<String, Object> req_ctx = ((BindingProvider)port).getRequestContext();
        req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, CvpConstants.DHL_WSDL);
        req_ctx.put("javax.xml.ws.client.connectionTimeout", "60000");

        String userpassword = CvpConstants.DHL_USER + ":" + CvpConstants.DHL_PASSWORD;
        String encodedAuthorization = Base64.encode(userpassword.getBytes());
         
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put("Authorization", Collections.singletonList("Basic " + encodedAuthorization));
        
        req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);

        CreateShipmentOrderResponse createShipmentOrder = port.createShipmentOrder(request);

How can I add this header to the soap call?

  • do you maybe have a typo in `Authentification`? – TZHX Jul 14 '22 at 11:23
  • No the line of code didn't work, so I removed it. – Till Glöckner Jul 14 '22 at 11:26
  • Is there a specific library that you use to generate the classes from WSDL ? AXIS2 or CXF or something similar ? – Ramachandran.A.G Jul 14 '22 at 11:47
  • Yes I used AXIS2 – Till Glöckner Jul 14 '22 at 11:51
  • Did a quick wsdl2java and I can see that the Authentification is created ``` public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( "http://dhl.de/webservice/cisbase", "Authentification", "ns1"); /** field for Authentification */ protected AuthentificationType localAuthentification; public AuthentificationType getAuthentification() { return localAuthentification; } ``` It should get set from the client , can you use fiddler or something similar to see if the header is set indeed ? – Ramachandran.A.G Jul 14 '22 at 15:34
  • Unfortunately the header is not filled. – Till Glöckner Jul 15 '22 at 12:16

1 Answers1

1

Benjamin Müller gives the answer to your question under the following link.A few objects (actually only names) still have to be adjusted.

Java WSDL DHL Classes

The two lines below the following line must be used, otherwise the authentication will not work.

// overwrite BasicAuth Username and Password

This is the only way DHL will not reject the request with "SECURITY_VIOLATION". All other ways are not approved by DHL and lead to an error message.

Chris
  • 36
  • 5