Isabelle Sampaio wrote:

I'm new and I'm not sure if someone has asked this before, if that's the
case, sorry, guys :)

Anyway, I'm trying to invoke a service that returns a complex type (let's
say, "blah"), and as you must know it's necessary to map the type:


QName qn = new QName( targetNS, className);
service.mapType( qn, Class.forName(classLocation));

Currently, I'm presuming the user of my class knows the targetNS for that
complexType, but unfortonately, that's not possible. Does anyone knows how
to get the targetnamespace for a complex type? I know I can get the
targetnamespace using this command:
(presuming I've read the wsdl already)

System.out.println(def.getNamespaces());
In my sample, the result would be:
{impl=http://cit05:8080/axis/services/ServerFileTrans,
intf=http://cit05:8080/axis/services/ServerFileTrans,
wsdlsoap=http://schemas.xmlsoap.org/wsdl/soap/,
apachesoap=http://xml.apache.org/xml-soap,
soapenc=http://schemas.xmlsoap.org/soap/encoding/,
xsd=http://www.w3.org/2001/XMLSchema,
wsdl=http://schemas.xmlsoap.org/wsdl/,
tns1=urn:ServerFileTrans, =http://schemas.xmlsoap.org/wsdl/}

The targetnamespace I need is named "tns1" in this case.

"tns1" is not namespace but only namespace prefix, namespace is "urn:ServerFileTrans" (i guess from debug output ..)

But that's not a
standart, I mean, it could be different. (I've seen "targetnamespaces"
with different names in other samples)

Is there any other way to get the TargetNameSpace for a ComplexType,
reading it from the WSDL? Could anyone please help me??


you could use WSDL4J <http://oss.software.ibm.com/developerworks/projects/wsdl4j> API <http://www.extreme.indiana.edu/apis/wsdl4j/> to walk WSDL and to get into types section and find complex type namespace and then register mapping for it

also you may want to look into how to invoke message without mapping i.e. to use XML directly (represented as DOM for example).

HTH,

alek

--
The best way to predict the future is to invent it - Alan Kay



Reply via email to