Axis2 - how to supply my own namespace prefixes?

I am using wsdl2java.exe to generate server code from a given WSDL.

The server code generated includes generic namespace prefixes like "ns1:", "ns2:", "ns3:".

I would like to instead specify custom prefixes for these, such as "abcglobal:", "abcmfg:", "abc:"

Is there a way to configure wsdl2java to do this?

I have read about the "-ns2p" option, and the "-em" option, but they don't seem to help.

LVL 13
Brian WithunAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sathish David Kumar NArchitectCommented: or wsdl2java.bat - Generates java code according to a given WSDL file to handle Web service invocation.
       These scripts can be found under the bin directory of the Axis2 distribution

check more info here

Sathish David Kumar NArchitectCommented:
Brian WithunAuthor Commented:
After much consideration I've discovered that if I need the namespace prefixes to be certain specific things, then I'm doing something wrong.

However I parse the XML, I must be independent of the namespace prefixes.  Those only exist to distinguish one namespace from another.

Be they "a:" and "b:" and "c:"

or "ns1:" and "ns2:" and "ns3:"

or "larry:" and "moe:" and "curley"

I must be able to parse them equally well.

This may explain why I can find no technique for affecting the namespace prefixes.  If I need to go down that road then I am already lost.

I have updated my software to be namespace-independent.

I had been using the XML_ParserCreate() to parse the XML, and it was making callbacks to my StartElement and  EndElement handlers supplying element names such as:


(where ns1 was defined as "urn:/University/body/v1.3")

...and I was comparing against "abcglobal:StudentName" -- this was a mistake.

Instead, I am using XML_ParserCreateNS("|") which makes the same callbacks to my handlers, but instead supplies element names like this:


-- and now I am looking for "urn:/University/body/v1.3|StudentName" -- which is independent of whether it had a namespace prefix of "abcglobal:" or "ns1"


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sathish David Kumar NArchitectCommented:
gd work .... :) i too learn something thanks....
Brian WithunAuthor Commented:
My own answer was either completely correct, or sufficiently correct.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.