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 Eric Chow <er...@gmail.com> on 2006/08/29 05:42:53 UTC

Return a JavaBean in Axis2

Hello,

How can I return a JavaBean class in Axis2 web service ?
I wrote a simple service and client with Axis2 but failed and showed
the following exceptions. The following is my codes:

package test.service;

/**
 * EchoService.java
 *
 * @author Chao Hoi Ka, Eric
 *
 */
public class EchoService {
	public User echo(User u) {
		System.out.println("Receive: " + u.getName());
		
		u.setName(u.getName() + "...BACKED");
		
		return u;
	}
}



package test.service;

import java.util.Date;

/**
 * User.java
 *
 * @author Chao Hoi Ka, Eric
 *
 */
public class User {
	private String name;
	private Date birth;
	public Date getBirth() {
		return this.birth;
	}
	public void setBirth(Date birth) {
		this.birth = birth;
	}
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}		
}




<?xml version="1.0" ?>
<service>
	<parameter name="ServiceClass"
locked="false">test.service.EchoService</parameter>
	<operation name="echo">
		<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
	</operation>
</service>





log4j:WARN No appenders could be found for logger
(org.apache.axiom.om.impl.builder.StAXOMBuilder).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.apache.axis2.AxisFault: namespace
mismatch require http://service.test/xsd found http:///xsd
	at org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:287)
	at test.client.EchoserviceStub.echo(EchoserviceStub.java:133)
	at test.client.Client.main(Client.java:39)
Caused by: java.lang.Exception: org.apache.axis2.AxisFault: namespace
mismatch require http://service.test/xsd found http:///xsd
	at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:89)
	at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37)
	at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454)
	at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284)
	at org.apache.axis2.transport.http.HTTPWorker.processRequest(HTTPWorker.java:255)
	at org.apache.axis2.transport.http.server.SimpleConnectionThread.run(SimpleConnectionThread.java:92)
	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
	at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
	at java.lang.Thread.run(Thread.java:595)

	at org.apache.axis2.AxisFault.<init>(AxisFault.java:159)
	... 3 more

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


Re: Return a JavaBean in Axis2

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Eric ;

When you send the request namesapce of the body first child should be
"http://service.test/xsd", pls try to put that and see.

Thanks
Deepal

Eric Chow wrote:

> Hello,
>
> How can I return a JavaBean class in Axis2 web service ?
> I wrote a simple service and client with Axis2 but failed and showed
> the following exceptions. The following is my codes:
>
> package test.service;
>
> /**
> * EchoService.java
> *
> * @author Chao Hoi Ka, Eric
> *
> */
> public class EchoService {
>     public User echo(User u) {
>         System.out.println("Receive: " + u.getName());
>        
>         u.setName(u.getName() + "...BACKED");
>        
>         return u;
>     }
> }
>
>
>
> package test.service;
>
> import java.util.Date;
>
> /**
> * User.java
> *
> * @author Chao Hoi Ka, Eric
> *
> */
> public class User {
>     private String name;
>     private Date birth;
>     public Date getBirth() {
>         return this.birth;
>     }
>     public void setBirth(Date birth) {
>         this.birth = birth;
>     }
>     public String getName() {
>         return this.name;
>     }
>     public void setName(String name) {
>         this.name = name;
>     }       
> }
>
>
>
>
> <?xml version="1.0" ?>
> <service>
>     <parameter name="ServiceClass"
> locked="false">test.service.EchoService</parameter>
>     <operation name="echo">
>         <messageReceiver
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
>     </operation>
> </service>
>
>
>
>
>
> log4j:WARN No appenders could be found for logger
> (org.apache.axiom.om.impl.builder.StAXOMBuilder).
> log4j:WARN Please initialize the log4j system properly.
> Exception in thread "main" org.apache.axis2.AxisFault: namespace
> mismatch require http://service.test/xsd found http:///xsd
>     at
> org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:287)
>
>     at test.client.EchoserviceStub.echo(EchoserviceStub.java:133)
>     at test.client.Client.main(Client.java:39)
> Caused by: java.lang.Exception: org.apache.axis2.AxisFault: namespace
> mismatch require http://service.test/xsd found http:///xsd
>     at
> org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:89)
>
>     at
> org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37)
>
>     at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454)
>     at
> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284)
>
>     at
> org.apache.axis2.transport.http.HTTPWorker.processRequest(HTTPWorker.java:255)
>
>     at
> org.apache.axis2.transport.http.server.SimpleConnectionThread.run(SimpleConnectionThread.java:92)
>
>     at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>
>     at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>
>     at java.lang.Thread.run(Thread.java:595)
>
>     at org.apache.axis2.AxisFault.<init>(AxisFault.java:159)
>     ... 3 more
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>

-- 
Thanks,
Deepal
................................................................
~Future is Open~ 



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