javax.xml.soap.SOAPException:标题子元素“用户名"必须是命名空间限定的 [英] javax.xml.soap.SOAPException: Header child element 'username' must be namespace qualified

查看:74
本文介绍了javax.xml.soap.SOAPException:标题子元素“用户名"必须是命名空间限定的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发soap网络服务.我在tomcat中运行成功.但是当我将它部署到 weblogic 时,发生了错误.我正在从标题向 Web 服务发送用户名和密码,但出现如下错误:

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>

有什么想法吗?

推荐答案

虽然 SOAP 标准确实要求标头元素是命名空间限定的,但似乎只有 weblogic 实现会检查这一点.Tomcat 使用 JDK 实现,它接受没有命名空间的标头.

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.

要在 weblogic 中进行相同的设置,您必须在 war 文件中包含 saaj-impl 并告诉 weblogic 您要在 weblogic.xml 文件中使用该实现.

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.

weblogic.xml 中的相关部分:

relevant part in weblogic.xml:

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

如果您使用的是 maven,请添加此项以在您的包中包含 saaj-impl.

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>

这篇关于javax.xml.soap.SOAPException:标题子元素“用户名"必须是命名空间限定的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆