1

I have web-service implementation in java using Axis-1.4, to search the session, which is created from my application.

like,

findByName(name) which return the complex type map>.

So, whenever i invoked the webservice it will return me the result in complex type. the outer map key will represents the number records i got for specific name, and the inner map will contains the key and value base on my application configuration.

When I received the response the return complextype which is incorporated between <item xmlns=""> with xmlns="" value blank.

The problem i faced is value of xmlns must not be empty due to which my client response parsing is failed. And value required is xmlns="http://xml.apache.org/xml-soap"

here is the response which i got is

<findByNameResponse xmlns="http://session.provider"> 
  <findByNameReturn xsi:type="ns1:Map" xmlns:ns1="http://xml.apache.org  /xml-soap">
    <item xmlns="">
     <key xsi:type="xsd:string">1</key>
     <value xsi:type="ns1:Map">
     <item>
        <key xsi:type="xsd:string">username</key>
       <value xsi:type="xsd:string">myname</value>
     </item>
     </value>
    </item>
</findByNameReturn>
</findByNameResponse>

wsdd having <operation> for findByName is:

<ns3:operation name="findByName" qname="ns1:findByName" returnQName="ns1:findByNameReturn" returnType="ns2:Map" soapAction="" xmlns:ns1="http://session.provider" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:ns3="http://xml.apache.org/axis/wsdd/">
   <ns3:parameter qname="ns1:name" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
</ns3:operation>

I also go through the source of axis-1.4.jar and jaxrpc.jar and from that i found that the RPCParameter was changed internally. Also found https://issues.apache.org/jira/browse/AXIS-2385 So, i was not unble to understand if there is an issue with my wsdd file or it is bug in axis itself or any work around to solve this problem?

  • " And value required is xmlns="http://xml.apache.org/xml-soap"" - why would your client *require* it to be a particular namespace? That sounds like a very broken client to me... or you're misdiagnosing it. – Jon Skeet Jul 31 '15 at 11:44
  • Thanks @JonSkeet I also think the same way as we have multiple webservices with different wsdl and when client load it all at the same time, they faced namespace collision too. but i still have to fix it :(. – sanjay dhamelia Jul 31 '15 at 12:10

1 Answers1

0

I solved this problem, So you can write a BasicHandler like Ian McLaird's Answer and remove from Attribute like this,

if(originalNodeName.equalsIgnoreCase("item")){
     if (childNode instanceof Element){
          Element element = (Element) childNode;
          final String xmlns = element.getAttribute("xmlns");
          if (xmlns != null && xmlns.isEmpty()){
             element.removeAttribute("xmlns");
          }
      }
}

But Don't remember, you should go deep Dom Tree with loop...

Hope this help..

Community
  • 1
  • 1
iceberg
  • 1,951
  • 1
  • 22
  • 26