Search code examples
javascalaauthenticationsoapjax-ws

How to pass Authentication Header to JAXWS SOAP client


I have generated classes for soap client using wsimport.exe.

My request should look like

POST /posaservice/servicemanager.asmx HTTP/1.1
Host: ****
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.pininteract.com/BalanceInquiry"

<?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>
    <AuthenticationHeader xmlns="http://www.pininteract.com">
      <userId>VALUE</userId>
      <password>VALUE</password>
    </AuthenticationHeader>
  </soap:Header>
  <soap:Body>
    <BalanceInquiry xmlns="http://www.pininteract.com" />
  </soap:Body>
</soap:Envelope>

But I don't know how to pass parameters to Authentication Header part. Currently my code looks like

val client = new ServiceManager().getServiceManagerSoap()
var res = client.balanceInquiry()
println(res)

I have class AuthenticationHeader among others generated, but I don't know how to use it.


Solution

  • Actually after more search through stackoverflow I found solution to my problem How do I add a SOAP Header using Java JAX-WS