You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Rhimbo <rh...@yahoo.com> on 2006/04/13 19:17:34 UTC

How to set return type with QName in DII client?

Can anyone point me to a _good_ explanation of QName?  Specifically,
I'm having trouble setting the return type for a call to a web
service client that returns a Java Bean. 

A web service end point returns an instance of "Session", which is 
an interface I defined.  Actually it returns an instance of 
"PlayerSession", which is a Java Bean that implements the "Session" 
interface.

I'm trying this: 

    String myEndpoint = "http://localhost:8080/axis/services/....."

    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(new java.net.URL(myEndpoint));
    call.setOperationName("getSession");

    call.addParameter(new QName("uid"),
	              new QName("int"),
                      ParameterMode.IN);
    Integer i1 = new Integer(100);
    call.setReturnType(new QName("Session"));         <--------

    call.invoke(new QName("getSession"), new Object [] {i1});

The line at "<---" is giving me trouble.  What do I enter here?

The org.apache.axis.client.Call Javadoc for 
    setReturnType(QName type) 
says 
    type - QName of the return value type.

(not terribly useful).

The Javadoc for 
    setReturnType(QName xmlType,
                  java.lang.Class javaType)
says
    xmlType - - QName of the data type of the return value
    javaType - - Java class of the return value

Hmm.  What is the QName?  What is the "local part" and what is
the namespace URI?  

When I execute my client, I get the following exception:

; nested exception is:
        org.xml.sax.SAXParseException: Premature end of file.


Can anyone point me to some good documentation, something other 
than the W3C "Namespaces in XML" document? 
   

Thanks,

V



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: How to set return type with QName in DII client?

Posted by Anne Thomas Manes <at...@gmail.com>.
QName means qualified name.
A QName comprises two parts: a namespace and a local name.

A namespace is a URI that uniquely defines a set of names. When you define a
WSDL or XML Schema file, you should always specify a target namespace. All
entities defined in the WSDL or schema will belong to that target namespace.
The local name is the name of an individual entity in the WSDL or schema.
For example, let's look at the definition of a complexType call "foo":

<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="urn:foo.sample"
  xmlns:tns="urn:foo.sample">
  <xsd:complexType name="foobar">
    <xsd:sequence>
      <xsd:element name="bar" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

The QName for the foo type is "tns:foo" or more accurately, "urn:foo.sample
}foo".

See the JavaDoc for the definition of the Java QName class:
http://java.sun.com/webservices/docs/1.6/api/javax/xml/namespace/QName.html.


Anne

On 4/13/06, Rhimbo <rh...@yahoo.com> wrote:
>
> Can anyone point me to a _good_ explanation of QName?  Specifically,
> I'm having trouble setting the return type for a call to a web
> service client that returns a Java Bean.
>
> A web service end point returns an instance of "Session", which is
> an interface I defined.  Actually it returns an instance of
> "PlayerSession", which is a Java Bean that implements the "Session"
> interface.
>
> I'm trying this:
>
>     String myEndpoint = "http://localhost:8080/axis/services/....."
>
>     Service service = new Service();
>     Call call = (Call) service.createCall();
>     call.setTargetEndpointAddress(new java.net.URL(myEndpoint));
>     call.setOperationName("getSession");
>
>     call.addParameter(new QName("uid"),
>                       new QName("int"),
>                       ParameterMode.IN);
>     Integer i1 = new Integer(100);
>     call.setReturnType(new QName("Session"));         <--------
>
>     call.invoke(new QName("getSession"), new Object [] {i1});
>
> The line at "<---" is giving me trouble.  What do I enter here?
>
> The org.apache.axis.client.Call Javadoc for
>     setReturnType(QName type)
> says
>     type - QName of the return value type.
>
> (not terribly useful).
>
> The Javadoc for
>     setReturnType(QName xmlType,
>                   java.lang.Class javaType)
> says
>     xmlType - - QName of the data type of the return value
>     javaType - - Java class of the return value
>
> Hmm.  What is the QName?  What is the "local part" and what is
> the namespace URI?
>
> When I execute my client, I get the following exception:
>
> ; nested exception is:
>         org.xml.sax.SAXParseException: Premature end of file.
>
>
> Can anyone point me to some good documentation, something other
> than the W3C "Namespaces in XML" document?
>
>
> Thanks,
>
> V
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>