Finally I found a solution by deep and rigorous web search... http://stackoverflow.com/questions/74960/how-do-i-add-a-namespace-reference-to-a-soap-response-with-apache-axis2-and-wsdl2
explains how to do it. BUT: The result is not that nice. To be honest: I forgot to mention that I generated the client code with WSDL2Java and wanted to use the generated stu(b|ff) just as it fell on my HD. The solution presented on the page urled above basically supports this approach by adding minimal extensions to the generated code. BUT: (1) You have to add the extension to every method request implementation in the generated code. At least every method implementation your client code will use :-) (2) The approach is to add a namespace declaration as early as possible to the envelope generated. Thats quite fine, but its not early enough: The SOAP message body is already constructed and already contains its own namespace declaration(s) as required, when the envelope is generated. Thus the namespace in question (or: all namespaces in question) tend(s) to be declared twice: In the envelope and at (their) first occurrence in the body. (3) The SOAP header is generated *after* adding the namespace declaration in this approach, but its visibility scope downwards into the element hierarchy is only "1 step", that is: Elements directly beneath the Header element make use of the namespace declared, but elements deeper inside will receive their own default namespace declaration -- using the same URL of course. Finally I do not yet have a confirmation that this format of SOAP call really will pass the XML security gateway. But calling the Web Service directly works fine :-) I will update this thread if there are relevant news :-) Christian > -----Original Message----- > From: Christian Gosch > Sent: Tuesday, September 22, 2009 3:30 PM > To: axis-user > Subject: How can I force namespace declarations in the envelope? (Axis2 > 1.4.1 / XMLbeans 2.3 / Java 1.4.2) > > Hi, > > by default, Axis2 seems to put namespace declarations like > 'xmlns:ns="http://my.namespace.com/this/one/is/it"' at the latest / > deepest point in the XML possible, which seems to be perfectly in line > with W3C requirements. > > My SOAP client has to talk to the Web Service via a XML security gateway > (probably Cisco ACE XML gateway) which is configured to require all > namespaces of the request to be declared in the SOAP envelope. > > How can I achieve that using Axis2 1.4.1? > > Environment: > - IBM WebSphere Application Server 6.0.2 / IBM Java 1.4.2 JRE (stuck to) > - Axis2 1.4.1 / XMLbeans 2.3.0 (only for client operation) > > > Examples: > > > That is what Axis2 currently produces, using simply the generated Java > stub class: > > <?xml version='1.0' encoding='UTF-8'?> > <soapenv:Envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> > <soapenv:Header> > <Request xmlns="http://premconn.premiereconnect.com/2007/02" > soapenv:mustUnderstand="0"> > <ReceiverKey>http://my.receiver.key/</ReceiverKey> > <RequestID>f0aFQR5s_AIBYHgdN16pqlf</RequestID> > <Authentication> > <XDDSAuth> > <RequesterID>###</RequesterID> > <Password>***</Password> > </XDDSAuth> > </Authentication> > </Request> > </soapenv:Header> > <soapenv:Body> > <ns:ListCreateRequest > xmlns:ns="http://premconn.premiereconnect.com/2007/02"> > <ns:SubmitId>f0aFQR5s_AIBYHgdN16pqlf</ns:SubmitId> > etc. etc. etc. > > > And *that* is what ACE XML gateway seems to expect: > > <?xml version='1.0' encoding='UTF-8'?> > <soapenv:Envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:ns="http://premconn.premiereconnect.com/2007/02"> > <soapenv:Header> > <ns:Request soapenv:mustUnderstand="0"> > <ns:ReceiverKey>http://my.receiver.key/</ns:ReceiverKey> > <ns:RequestID>f0aFQR5s_AIBYHgdN16pqlf</ns:RequestID> > <ns:Authentication> > <ns:XDDSAuth> > <ns:RequesterID>###</ns:RequesterID> > <ns:Password>***</ns:Password> > </ns:XDDSAuth> > </ns:Authentication> > </ns:Request> > </soapenv:Header> > <soapenv:Body> > <ns:ListCreateRequest> > <ns:SubmitId>f0aFQR5s_AIBYHgdN16pqlf</ns:SubmitId> > etc. etc. etc. > > > How can I force Axis2 to produce output that conforms to these > requirements? > > > Maybe this is related to Jira #AXIS2-4215 , URL: > https://issues.apache.org/jira/browse/AXIS2-4215 > > > Thanks in advance for useful hints and help, > -- > Dipl.-Inform. Christian Gosch, PMI PMP > Systems Architecture, Project Management > > inovex GmbH > Büro Pforzheim > Karlsruher Strasse 71 > D-75179 Pforzheim > Tel: +49 (0)7231 3191-85 > Fax: +49 (0)7231 3191-91 > c.go...@inovex.de > www.inovex.de > > Sitz der Gesellschaft: Pforzheim > AG Mannheim, HRB 502126 > Geschäftsführer: Stephan Müller > > > > > !DSPAM:4ab8d33e326661724765873! > >