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?
CodePudding user response:
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.