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 Ketan Deshpande <de...@yahoo.com> on 2005/03/04 04:54:11 UTC

Newbie question for Doc/literal web service using Axis

Hi all!

I am a newbie at this, so please be gentle... 

I am trying to write a web service that is document-literal. I am 
following the
example give in the Axis guide:
(I am using axis-1_2RC2)

1. Create an interface & Compile it to .class
public interface MyWebService {
  public String concatenate(String str1, String str2);
}
2. Generate WSDL from it: 
java -classpath %MY_CLASSPATH% org.apache.axis.wsdl.Java2WSDL -o 
myws.doc.wsdl
-u LITERAL --style DOCUMENT -l%MY_LOCATION% -n "urn:MyWebServiceNS"
MyWebService 

3. Now generate server code from it:
java -classpath %MY_CLASSPATH% org.apache.axis.wsdl.WSDL2Java -W -s -S 
true -o
server.doc.generated myws.doc.wsdl

When I run this, I get a NullPointerException on the Server side, in 
Axis code.


SOAPMonitor shows the client sending this message in the envelope:
<soapEnv:Body>
	<in0 xmlns="urn:MyWebServiceNS">A</in0>
	<in1 xmlns="urn:MyWebServiceNS">B</in1>
</soapEnv:Body>

When I looked into the server code, I saw that the server skeleton was 
more
like RPC or Wrapped:
    public java.lang.String concatenate(java.lang.String in0, 
java.lang.String
in1) throws java.rmi.RemoteException
    {
        java.lang.String ret = impl.concatenate(in0, in1);
        return ret;
    }


What am I doing wrong? Any pointers you can provide will be most 
gratefully
appreciated.

Thanks much!

-Ketan

=====
Ketan Deshpande
deshpande_ketan@yahoo.com

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

Re: Newbie question for Doc/literal web service using Axis

Posted by Anne Thomas Manes <at...@gmail.com>.
<flameOn>
The documentation in the user guide is terrible. You should always
start with WSDL -- not from Java.
</flameOn>

Here are some basic rules: 

If you want to generate a web service from your Java interface, then
you should always use wrapped/literal. Wrapped/literal supports
multiple parameters, whereas document/literal does not.

If you want to generate document/literal from your Java interface,
then you need to design your interface such that it accepts a single
object as input and returns a single object.

Better yet, write your WSDL first, and generate your Java code from it.

Anne  


On Fri, 04 Mar 2005 13:17:30 +0900, Bill Keese
<bi...@tech.beacon-it.co.jp> wrote:
> Do you really want document/literal rather than wrapped/literal?  Most
> people send messages like
> 
> <concatentate>
>   <in0>hello</in0>
>   <in0>world</in0>
> </concatenate>
> 
> ...which is wrapped literal (since the top tag is the name of the function).
> 
> Ketan Deshpande wrote:
> 
> >Hi all!
> >
> >I am a newbie at this, so please be gentle...
> >
> >I am trying to write a web service that is document-literal. I am
> >following the
> >example give in the Axis guide:
> >(I am using axis-1_2RC2)
> >
> >1. Create an interface & Compile it to .class
> >public interface MyWebService {
> >  public String concatenate(String str1, String str2);
> >}
> >2. Generate WSDL from it:
> >java -classpath %MY_CLASSPATH% org.apache.axis.wsdl.Java2WSDL -o
> >myws.doc.wsdl
> >-u LITERAL --style DOCUMENT -l%MY_LOCATION% -n "urn:MyWebServiceNS"
> >MyWebService
> >
> >3. Now generate server code from it:
> >java -classpath %MY_CLASSPATH% org.apache.axis.wsdl.WSDL2Java -W -s -S
> >true -o
> >server.doc.generated myws.doc.wsdl
> >
> >When I run this, I get a NullPointerException on the Server side, in
> >Axis code.
> >
> >
> >SOAPMonitor shows the client sending this message in the envelope:
> ><soapEnv:Body>
> >       <in0 xmlns="urn:MyWebServiceNS">A</in0>
> >       <in1 xmlns="urn:MyWebServiceNS">B</in1>
> ></soapEnv:Body>
> >
> >When I looked into the server code, I saw that the server skeleton was
> >more
> >like RPC or Wrapped:
> >    public java.lang.String concatenate(java.lang.String in0,
> >java.lang.String
> >in1) throws java.rmi.RemoteException
> >    {
> >        java.lang.String ret = impl.concatenate(in0, in1);
> >        return ret;
> >    }
> >
> >
> >What am I doing wrong? Any pointers you can provide will be most
> >gratefully
> >appreciated.
> >
> >Thanks much!
> >
> >-Ketan
> >
> >=====
> >Ketan Deshpande
> >deshpande_ketan@yahoo.com
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam?  Yahoo! Mail has the best spam protection around
> >http://mail.yahoo.com
> >
> >
> >
> >
>

Re: Newbie question for Doc/literal web service using Axis

Posted by Bill Keese <bi...@tech.beacon-it.co.jp>.
Do you really want document/literal rather than wrapped/literal?  Most 
people send messages like

<concatentate>
  <in0>hello</in0>
  <in0>world</in0>
</concatenate>

...which is wrapped literal (since the top tag is the name of the function).

Ketan Deshpande wrote:

>Hi all!
>
>I am a newbie at this, so please be gentle... 
>
>I am trying to write a web service that is document-literal. I am 
>following the
>example give in the Axis guide:
>(I am using axis-1_2RC2)
>
>1. Create an interface & Compile it to .class
>public interface MyWebService {
>  public String concatenate(String str1, String str2);
>}
>2. Generate WSDL from it: 
>java -classpath %MY_CLASSPATH% org.apache.axis.wsdl.Java2WSDL -o 
>myws.doc.wsdl
>-u LITERAL --style DOCUMENT -l%MY_LOCATION% -n "urn:MyWebServiceNS"
>MyWebService 
>
>3. Now generate server code from it:
>java -classpath %MY_CLASSPATH% org.apache.axis.wsdl.WSDL2Java -W -s -S 
>true -o
>server.doc.generated myws.doc.wsdl
>
>When I run this, I get a NullPointerException on the Server side, in 
>Axis code.
>
>
>SOAPMonitor shows the client sending this message in the envelope:
><soapEnv:Body>
>	<in0 xmlns="urn:MyWebServiceNS">A</in0>
>	<in1 xmlns="urn:MyWebServiceNS">B</in1>
></soapEnv:Body>
>
>When I looked into the server code, I saw that the server skeleton was 
>more
>like RPC or Wrapped:
>    public java.lang.String concatenate(java.lang.String in0, 
>java.lang.String
>in1) throws java.rmi.RemoteException
>    {
>        java.lang.String ret = impl.concatenate(in0, in1);
>        return ret;
>    }
>
>
>What am I doing wrong? Any pointers you can provide will be most 
>gratefully
>appreciated.
>
>Thanks much!
>
>-Ketan
>
>=====
>Ketan Deshpande
>deshpande_ketan@yahoo.com
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>
>
>  
>