creating service

stanfordia's picture
Hello,

I am developping a service with Axis2 like that :
I generate the cleint stub of the class that implements the services
and the in the server side I create the service like that :

if (context==null) {
try {
context = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
} catch (Exception e) {
e.printStackTrace();

}
}
try
{
AxisService service=AxisService.createService(MyService.class.getName(), context.getAxisConfiguration(), RPCInOutAsyncMessageReceiver.class);

service.setActive(true);
context.getAxisConfiguration().addService(service);
SimpleHTTPServer server = new SimpleHTTPServer(context, 1500);
server.start();
} catch (AxisFault e) {
e.printStackTrace();

}

while (true) {
try {
System.out.println ("waiting 10 sec");
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}


Is it correct?
wheb I excute it there is the following message:
11 févr. 2008 13:06:58 org.apache.axis2.deployment.ModuleDeployer deploy
INFO: Deploying module: addressing-1.2

In the client side I have the following application:

try
{
String eprString= "http://127.0.0.1:1500/axis2/services/MyService";
MyServiceMyServiceSOAP11PortStub stub=new MyServiceMyServiceSOAP11PortStub(eprString);

MyServiceMyServiceSOAP11PortStub.GetDataResponse repData=new MyServiceMyServiceSOAP11PortStub.GetDataResponse();
repData= stub.getData();
System.out.println("Reponse: "+ repData.get_return());
MyServiceMyServiceSOAP11PortStub.SetData testSetdata =new MyServiceMyServiceSOAP11PortStub.SetData();
testSetdata.setData("Modification");

stub.setData(testSetdata);

} catch (Exception e) {
e.printStackTrace();

}

}

but I have an error when I call a method like setData in this code or getData
for getData I have the following error:

*Exception in thread "Axis2 Task" java.lang.IllegalStateException: Response already committed*
* at org.apache.axis2.transport.http.server.AxisHttpResponseImpl.assertNotCommitted(AxisHttpResponseImpl.java:85)*
* at org.apache.axis2.transport.http.server.AxisHttpResponseImpl.setContentType(AxisHttpResponseImpl.java:136)*
* at org.apache.axis2.transport.http.CommonsHTTPTransportSender.sendUsingOutputStream(CommonsHTTPTransportSender.java:259)*
* at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:203)*
* at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:452)*
* at org.apache.axis2.receivers.AbstractInOutAsyncMessageReceiver$1.handleResult(AbstractInOutAsyncMessageReceiver.java:42)*
* at org.apache.axis2.receivers.AbstractInOutAsyncMessageReceiver$2.run(AbstractInOutAsyncMessageReceiver.java:67)*
* at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)*
* at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)*
* at java.lang.Thread.run(Unknown Source)*


And when I call a method whith no return value such as setData I have the following error:
Exception in thread "Axis2 Task" java.lang.UnsupportedOperationException: An access occurred that is not valid.
at org.apache.axis2.description.InOnlyAxisOperation.getMessage(InOnlyAxisOperation.java:105)
at org.apache.axis2.util.MessageContextBuilder.createOutMessageContext(MessageContextBuilder.java:180)
at org.apache.axis2.receivers.AbstractInOutAsyncMessageReceiver$2.run(AbstractInOutAsyncMessageReceiver.java:58)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Unknown Source)

 

I don't undersatand perhaps there is something missing in the initialization of the server !!!!
Tanks for your help,

 

 

deepal's picture

please change AxisService

please change AxisService service=AxisService.createService(MyService.class.getName(), context.getAxisConfiguration(), RPCInOutAsyncMessageReceiver.class); with service = AxisService.createService( MyService.class.getName()), configurationContextFromFileSystem.getAxisConfiguration());   Other than that I can not see any problem , it would be great if you can send this is wsas-user  list or Axis list, or create a jira   Thanks Deepal
deepal's picture

please refer

please refer to http://wso2.org/library/2546
library project main code
Learn Cloud
Learn
Cloud

The WSO2 Application Server is a reliable application server that can host your enterprise web applications. The WSO2 Application Server as a Service is offered in StratosLive, the WSO2 Platform as a Service. This article explains how a simple web application can be developed and deployed from Carbon Studio to the WSO2 Application Server...

Latest Webinar
Different groups within an organization need to monitor different Key Performance Indicators (KPIs) - An operations team will be interested in the response times of business services and loads of each service,..
Thursday, February 9th 2012, 09.00 AM (PST)

Thursday, February 9th 2012, 10.00 AM (GMT)