axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "albert quinn" <albertber...@gmail.com>
Subject Re: POJO Web Service yes or not question
Date Tue, 17 Jul 2007 15:50:03 GMT
  Hi David !! :

  First of all, many thanks for spending your time with my newbie (and
probably obvious questions for an advanced user) questions, but I've
just come to the Axis World and I'm totally lost and needing lots of
help after reading the Axis 2 docs.

  Second... I think I've not explained my problem very well, so I'll
try again : I've read the Axis 2 docs. I've probed the POJO samples
and then I've started to try things to check if a POJO web service
could do all I need. So I've tried this :

  I've this two classes :

package code;

public class ExternalClass {
	
	private boolean error = false;
	private String message = null;
	private InternalClass internalClass = null;
	
	public ExternalClass(boolean error, String message, InternalClass
internalClass) {
  	  this.error = error;
	  this.message = message;
	  this.internalClass = internalClass;
	}

// getters and setters...

}

package code;

public class InternalClass {

	private String internalMessage = null;

	public InternalClass(String internalMessage) {
		this.internalMessage = internalMessage;
	}

 // get and set methods.	
}


Then I've this web service :

package code;

public class WebServiceTest {

	public ExternalClass returnExternalClass() {
		return new ExternalClass(true, "external message", new
InternalClass("internal message") );
	}
	
}

Then I've deployed that POJO web service using the "Axis 2 Service
archiver" Eclipse plugin and then I've done this RPC client :

package code;

// import sentences

public class WebServiceTestClient {

	public static void main(String[] args) {
		try {
			RPCServiceClient rpcClient = new RPCServiceClient();
			Options oOptions = rpcClient.getOptions();
	        EndpointReference epr = new
EndpointReference("http://localhost:8080/axis2/services/WebServiceTest/returnExternalClass");
	        oOptions.setTo(epr);
	        QName op = new QName("http://code/xsd", "returnExternalClass");
			
	        Object[]  arguments = new Object[] { };
	        Class[] returnTypes  = new Class[]  { ExternalClass.class };
	        Object[] response = rpcClient.invokeBlocking(op, arguments,
returnTypes);
	
	        ExternalClass externalClass = (ExternalClass) response[0];
	        if(externalClass == null)
	        	System.out.println("ExternalClass == NULL");
	        else {
	        	System.out.println("error            : " + externalClass.isError() );
	        	System.out.println("external message : " +
externalClass.getMessage() );
	        	InternalClass internalClass = externalClass.getInternalClass();
	        	if(internalClass == null)
	        		System.out.println("InternalClass = NULL");
	        	else
	        		System.out.println("internal message        : " +
internalClass.getInternalMessage() );
	        		
	        }	
  } catch (AxisFault oAxisFault) {
      System.out.println("ERROR !!!!! Fault.");
      oAxisFault.printStackTrace();
  } catch(Exception oException) {
      System.out.println("ERROR !!!!! Excepction.");
      oException.printStackTrace();
  }
 }
}

Then I've run the client and I've got this Exception :


ERROR !!!!! Fault.
org.apache.axis2.AxisFault: Exception occurred while trying to invoke
service method returnExternalClass
	at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:434)
	at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:373)
	at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:294)
	at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:520)
	at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:500)
	at org.apache.axis2.rpc.client.RPCServiceClient.invokeBlocking(RPCServiceClient.java:97)
	at code.WebServiceTestClient.main(WebServiceTestClient.java:23)


  So, the question is : can a POJO web service return something like
that? If so... any idea about what is happening here?. If not...
should I use ADB (I've read on Axis docs that ADB has problems with
complex types), XmlBeans?

  Thanks again in advance to anybody who help me !!!. Regards.




2007/7/17, david <david@davidwbrown.name>:
> Hello Albert, the POJO samples are RPC based services with clients that appear to work
as expected once the service is uploaded to the AXIS2 web app. HTH, David.
>
> albert quinn wrote ..
> >   Hi !!
> >
> >   A yes or not question : I want a POJO Web Service returning my own
> > objects from its methods, is that possible or have I to use any of the
> > Axis 2 databinding frameworks?
> >
> >   Thanks in advance to anybody who help me!!.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message