How to add header to soap request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bur="http://test.com">
<soapenv:Header>
<bur:AuthHeader>
<Username></Username>
<Password></Password>
<REQUEST_ID>1</REQUEST_ID>
</bur:AuthHeader>
</soapenv:Header>
<soapenv:Body>
<bur:Add>
<AddReqDto>
<a>10</a>
<b>20</b>
/AddReqDto>
</bur:Add>
</soapenv:Body>
</soapenv:Envelope>
Then Net Bean generated code. It look like this:
SomeService service = new SomeService
QName portQName = new QName("http://services.somehost.com/" , "someservice");
String req = "<Add xmlns=\"http://services.somehost.com/\"><AddDto>1</AddReqDto></Add>";
try { // Call Web Service Operation
Dispatch<Source> sourceDispatch = null;
sourceDispatch = service.createDispatch(portQName, Source.class, Service.Mode.PAYLOAD);
Source result = sourceDispatch.invoke(new StreamSource(new StringReader(req)));
System.out.print( result.toString());
} catch (Exception ex) {
// TODO handle custom exceptions here
ex.printStackTrace();
}
So how to add this header to my SOAP request?