Khaled adel Khaled adel - 2 months ago 8x
Java Question

Get rid of empty xmlns element in JAX-WS

I am trying to generate a request like this using JAX-WS Client:

<soapenv:Envelope xmlns:soapenv="" xmlns:alin="" xmlns="">

But the request is generated like this:

<S:Envelope xmlns:S="" xmlns="">
<ns2:CustDtlsInqRq xmlns:ns2="">
<MsgRqHdr xmlns="">
<Body xmlns="">

the added tag
makes problems in server side
This is the code of my Handler that surround the request with SOAP Envelop

if (outboundProperty.booleanValue()) {

try {
SOAPMessage soapMessage = context.getMessage();

SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
soapEnvelope.addNamespaceDeclaration("", "");
// Grab the header of the SOAP envelop
SOAPHeader soapHeader = soapEnvelope.getHeader();

// Attach a new header if there is none...
if (soapHeader == null) {
soapHeader = soapEnvelope.addHeader();

soapMessage.writeTo(System.out); //TODO: remove this line (just for debugging)

} catch (Exception e) {
logger.error("Error Creating SOAP message", e);


How can I adjust the empty


I could solve the problem. By mistake I removed the generated file which include a header namespace definition for all the package classes

@javax.xml.bind.annotation.XmlSchema(namespace = "", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.ejada.sadadolp.bkf.mwservices.core;