bella
bella

Reputation: 1

javax.xml.soap.SOAPException: Header child element 'username' must be namespace qualified

I am developing soap web service. I run it successfully in tomcat. But when i deployed it to weblogic, en error occurred. I am sending username and password to web service from header but an error occurs as below:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vw="http://vw.com/">
  <soapenv:Header>
    <username>operator</username>
   <pass>xxxxxx</pass>      
   </soapenv:Header>
   <soapenv:Body>
      <vw:createParams>
       <!--Optional:-->
         <arg0>app1</arg0>
         <!--Optional:-->
         <arg1>All</arg1>
      </vw:createParams>
   </soapenv:Body>

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <ns0:Fault xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/"    
                 xmlns:ns1="http://www.w3.org/2003/05/soap-envelope">
         <faultcode>ns0:Server</faultcode>
         <faultstring>javax.xml.soap.SOAPException: Header child element 'username' must be namespace qualified!</faultstring>
      </ns0:Fault>
   </S:Body>
 </S:Envelope>

any idea?

Upvotes: 0

Views: 2771

Answers (3)

SrikanthM
SrikanthM

Reputation: 29

Even we had same issue, we were migrating from Weblogic 10.3.6 to Weblogic 12.2.1.4, our SOAP based webservices were started failing since we had custom authentication Header parameters like following:

<soapenv:Header>
    <username>admin</username>
    <password>welcome</password>
</soapenv:Header>

The above header was not getting authenticated since weblogic was mandating to for the child elements to have same schema for child elements with below error.

error message :

Caused by: javax.xml.soap.SOAPException: Header child element 'username' must be namespace qualified!

SOLUTION : New Header child elements has soapenv for child elements which was working.

<soapenv:Header>
<soapenv:username>admin</soapenv:username>
<soapenv:password>welcome</soapenv:password>
</soapenv:Header>

But the problem with above approach is we have more than 20+ webservice clients, all they are getting impacted, so weblogic team has suggested a tweak in JAVA_OPTIONS that resolved our issue. The validation error was suspended and all existing clients old code started working as is.

-Dprocesssoapheader=relax.

    

Upvotes: 1

Bahadır Yağan
Bahadır Yağan

Reputation: 5967

While it is true that SOAP standard requires header elements to be namespace qualified, it seems only the weblogic implementation checks that. Tomcat uses the JDK implementation which accepts headers without a namespace.

To have the same setup in weblogic, you have to include saaj-impl in your war file and tell weblogic you want to use that implementation in your weblogic.xml file.

relevant part in weblogic.xml:

<wls:prefer-application-packages>
  <wls:package-name>javax.xml.soap.*</wls:package-name>
</wls:prefer-application-packages>

If you are using maven, add this to have saaj-impl in your package.

<dependency>
  <groupId>com.sun.xml.messaging.saaj</groupId>
  <artifactId>saaj-impl</artifactId>
  <version>1.4.0</version>
</dependency>

Upvotes: 0

codebrane
codebrane

Reputation: 4650

SOAP requires header elements to be namespace qualified. If you're coding this, use QName for the username and pass elements

Upvotes: 0

Related Questions