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?
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"

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:
Sathish David Kumar NArchitectCommented:
gd work .... :) i too learn something thanks....
Brian WithunAuthor Commented:
My own answer was either completely correct, or sufficiently correct.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.