0

As a SOAP newbie I am following the same tutorial as given in Spring boot - Server did not recognize the value of HTTP Header SOAPAction. The tutorial can be found in https://howtodoinjava.com/spring-boot/spring-soap-client-webservicetemplate/amp/

Currently I am able to send the SOAP payload with the request needed. The server is responding to say I have not authenticated.

I therefore am trying to send the SOAP header with authentication detail along with this SOAP payload. See below examples.

Firstly, I have successfully managed to get the tutorial working. The request was sent with SOAP Action and response received.

Sent request [SaajSoapMessage {http://server.windeed.co.za/windeedengine/}CheckDeedsOfficeStatus]

The response is that I have not authenticated/sent authentication details correctly. I therefore created the Authentication Object with all the necessary details in order to marshall and make part of the SOAP message.

I tried the below:

ObjectFactory of = new ObjectFactory();
WinDeedCredentials cred = of.createWinDeedCredentials();

cred.setUsername("Test");
cred.setPassword("Test123");
cred.setCompany("COMPANY");
cred.setRequester("SOAP");
CheckDeedsOfficeStatus cdo = of.createCheckDeedsOfficeStatus();
CheckDeedsOfficeStatusResponse dr = (CheckDeedsOfficeStatusResponse)sc.callWebService(cdo,"http://server.windeed.co.za/windeedengine/CheckDeedsOfficeStatus");

The goal is to achieve this:

POST /windeedengine3/client.asmx HTTP/1.1
Host: server.windeed.co.za
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://server.windeed.co.za/windeedengine/CheckDeedsOfficeStatus"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <WinDeedCredentials xmlns="http://server.windeed.co.za/windeedengine/">
      <Username>string</Username>
      <Password>string</Password>
      <Company>string</Company>
      <Requester>string</Requester>
    </WinDeedCredentials>
  </soap:Header>
  <soap:Body>
    <CheckDeedsOfficeStatus xmlns="http://server.windeed.co.za/windeedengine/" />
  </soap:Body>
</soap:Envelope>

Currently, with the missing Authentication details, I am told I haven't authenticated correctly.

The expected result is the correct response from the server: Online or Offline. What is the correct way?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

I forgot to even revisit this topic. The problem was solved but I do not have the details immediately with me and need to travel to access them.

Prior to making the webservice call => sc.callWebService, it is important to inject the SOAP header details. I injected the xml header from SOAP UI into the code. Viola! It worked. Previously the MarshallSendAndReceive method was used with only the SoapActionCallback method. If I recall, I modified this to use WebServiceMessageCallback with an explicit definition of the xml header prior to making the webservice call.