org.apache.xml.security.c14n.CanonicalizationException:元素listFunctions具有相对名称空间:xmlns =" xxx_xxx_listFunctions"

时间:2014-12-23 14:07:44

标签: java xml web-services soap

我是Axis2和webservices的新手。我有一个axis2网络服务。当ws-security关闭时,事情运行良好。打开ws-security时,我在服务器日志中收到以下异常。我调试了没有调用的服务类方法。附件是两个service.xmls使用。

调用webservice的客户端获得了后续的soap错误 - prolog中的意外EOF

我在tomcat中得到以下java异常:

org.apache.xml.security.c14n.CanonicalizationException: Element listFunctions has a relative namespace: xmlns="test_vish_listFunctions"
    at org.apache.xml.security.c14n.implementations.Canonicalizer20010315.handleAttributesSubtree(Unknown Source)
    at org.apache.xml.security.c14n.implementations.CanonicalizerBase.canonicalizeSubTree(Unknown Source)
    at org.apache.xml.security.c14n.implementations.CanonicalizerBase.engineCanonicalizeSubTree(Unknown Source)
    at org.apache.xml.security.c14n.implementations.CanonicalizerBase.engineCanonicalizeSubTree(Unknown Source)
    at org.apache.xml.security.c14n.Canonicalizer.canonicalizeSubtree(Unknown Source)
    at org.apache.xml.security.utils.XMLUtils.outputDOM(Unknown Source)

以下是当ws-security关闭并且工作正常时的server.xml

    <service name="test_vish_listFunctions" targetNamespace="test_vish_listFunctions">
   <description>
        This service is to get the list  functions
   </description>
   <schema schemaNamespace="test_listFunctions"/>
   <parameter name="ServiceClass">vish.web.ws.service.ListFunctionsService</parameter>
   <operation name="listFunctions">
        <messageReceiver  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
   </operation>
   <module ref="soapmonitor"/>
 </service>

启用ws-security时的以下services.xml

<service name="test_vish_listRoutines" targetNamespace="test_vish_listRoutines">
   <description>Service description for test_vish_listRoutines</description>
  <schema schemaNamespace="test_vish_listRoutines"/>
  <parameter name="ServiceClass">test.web.ws.service.ListRoutinesService</parameter>
  <parameter name = "disasbleREST">true</parameter>
  <operation name="listRoutines">
  <messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
<module ref="soapmonitor"/>
<module ref="rampart" />
<parameter name = "InflowSecurity"><action>
<items>UsernameToken</items>
<passwordCallbackClass>test.web.ws.control.PWCBHandler</passwordCallbackClass>
</action>
</parameter>
</service>

1 个答案:

答案 0 :(得分:0)

我找出了问题并解决了问题。问题不在于Axis2。我的问题中列出的例外与XML Security的工作方式有关。 .aar文件中的services.xml具有targetNamespace =“test_vish_listRoutines”。使用WS-Security设置为true的Web服务的客户端代码正在使用此命名空间。它调用了'listRoutines',它是一个相对命名空间,在标准XMLSecurity中是不允许的。在serer端,与listRoutines相关的服务方法没有被调用。

更改为标准网址类型命名空间,例如'http://www.testing.com/webserice解决了问题。

松了一口气。希望这有帮助