Hi Hannes thank you for your intersest.
This is the code of the client :
======================================================================
public class Client {
/** Creates a new instance of Client */
public Client() {
}
public static void main(String args[]) {
String endpoint = new
String("http://localhost:8080/axis/services/Coordinatore");
Service service = new Service();
Call call = null;
try {
call = (Call) service.createCall();
} catch(javax.xml.rpc.ServiceException e) {}
call.setTargetEndpointAddress(endpoint);
call.setOperationName(new QName("avvia"));
call.addParameter("op",XMLType.XSD_INT,ParameterMode.IN);
call.setReturnType(XMLType.XSD_INT);
try {
call.invoke( new Object [] {});
} catch(java.rmi.RemoteException e) {
System.err.println("catch chiamata a avvia-> " );
e.printStackTrace();
}
System.exit(0);
}
}
==========================================================================
This is the code for service A :
=============================================================================
public class Coordinatore {
/**
* Creates a new instance of Coordinatore
*/
public Coordinatore() {
}
public void avvia () {
TransactionManagerImpl wstm = TransactionManagerImpl.getInstance();
try {
wstm.begin();
String endpoint = new
String("http://localhost:8080/axis/services/Servizio1");
Service service = new Service();
Call call = null;
SandeshaContext ctx = new SandeshaContext(true);
ctx.setAcksToURL("http://localhost:8080/axis/services/RMService");
ctx.setReplyToURL("http://localhost:8080/axis/services/RMService");
ctx.setSourceURL("http://localhost:8080/axis/services/RMService");
try {
call = (Call) service.createCall();
} catch(javax.xml.rpc.ServiceException e) {
System.out.println("problemi create call");
}
ctx.initCall(call, endpoint, "urn:wsrm:somma",
Constants.ClientProperties.IN_OUT);
call.setOperationName("somma");
call.setSOAPActionURI("http://localhost:8080/axis/services/kandulaServizio1#somma");
call.addParameter( "op1", XMLType.XSD_INT,
ParameterMode.IN);
call.addParameter( "op2", XMLType.XSD_INT,
ParameterMode.IN);
call.setReturnType( XMLType.XSD_INT );
Integer op1 = new Integer(1);
Integer op2 = new Integer(2);
Integer ris;
try {
ctx.setLastMessage(call);
ris = (Integer) call.invoke( new Object [] {op1,op2});
System.out.println("ris = " + ris.intValue());
RMReport report = ctx.endSequence();
System.out.println("Is all messages acked - " +
report.isAllAcked());
} catch(java.rmi.RemoteException e) {
System.err.println("catch CoordinatoreInvoke-> " + e);
e.printStackTrace();
}
wstm.commit();
}catch(Exception e) {
System.out.println("Errore in Coordinatore");
e.printStackTrace();
}
}
}
=====================================================================================0
this is the code of Service B
========================================================================================
public class Servizio1 {
private static TransactionManager tm;
public Servizio1() {
tm = Bridge.getInstance().getTM();
}
public int somma (int op1, int op2) throws RollbackException,
SystemException {
int ris = -1;
try{
Risorsa1 r = getRisorsa();
System.out.println("Servizio1 : somma");
ris = r.somma(op1,op2);
closeRisorsa(r);
}catch (Exception e) {
System.out.println("RollbackException :" + e);
}
return (ris);
}
private Risorsa1 getRisorsa() throws RollbackException, SystemException {
Risorsa1 r = Risorsa1.getInstance();
tm.getTransaction().enlistResource(r);
return r;
}
private void closeRisorsa(Risorsa1 r) throws SystemException {
tm.getTransaction().delistResource(r, XAResource.TMSUSPEND);
}
}
=============================================================
Servizio1 (service B) uses the class Risorsa1:
=============================================================
public class Risorsa1 implements NamedXAResource{
private Xid tx;
private static Risorsa1 instance = null;
/**
* Creates a new instance of Risorsa1
*/
protected Risorsa1() {
tx = null;
}
public void commit(Xid arg0, boolean arg1) throws XAException {
System.out.println("Risorsa1 commit");
}
public void end(Xid arg0, int arg1) throws XAException {
System.out.println("Risorsa1 end");
}
public void forget(Xid arg0) throws XAException {
System.out.println("Risorsa1 forget");
}
public static Risorsa1 getInstance() {
if (instance == null)
{
instance = new Risorsa1();
}
return instance;
}
public String getName() {
return("Risorsa1");
}
public int getTransactionTimeout() throws XAException {
System.out.println("Risorsa1 getTransactionTimeout");
return 0;
}
public boolean isSameRM(XAResource arg0) throws XAException {
System.out.println("Risorsa1 isSameRM");
return arg0 == this;
}
public int prepare(Xid arg0) throws XAException {
System.out.println("Risorsa1 prepare");
if (tx.equals(arg0))
return XAResource.XA_OK;
throw new XAException();
}
public Xid[] recover(int arg0) throws XAException {
System.out.println("Risorsa1 recover");
return null;
}
public void rollback(Xid arg0) throws XAException {
System.out.println("Risorsa1 rollback");
}
public boolean setTransactionTimeout(int arg0) throws XAException {
System.out.println("Risorsa1 setTransactionTimeout");
return false;
}
public int somma(int op1, int op2){
return(op1+op2);
}
public void start(Xid arg0, int arg1) throws XAException {
System.out.println("Risorsa1 start");
this.tx = arg0;
}
}
======================================================
----- Original Message -----
From: "Hannes Erven" <[EMAIL PROTECTED]>
To: "Valerio Vianello" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Monday, July 17, 2006 2:44 PM
Subject: Re: kandula and sandesha
Hi Valerio,
Please show us your code for all your web services that are involved.
thanks
-hannes
PS.: Please keep replies on the list.
Valerio Vianello wrote:
Hi Hannes,
my goal is to develop an example using both kandula and sandesha on axis
1.3
I've made a client that calls a service A which in turn invokes a
service B in a reliabile and transactional way (the invoke to the service
B done by the service A is done in the part of the code that I send you
before).
I've used separately both frameworks and all seem to work, but then I
tried to
join kandula and sandesha I have an error
First I had this error: org.apache.axis.types.URI$MalformedURIException:
Cannot initialize URI with empty parameters
then Jaliya (sandesha developer) sended me a new version of sandesha and
the error became :
==========================================================================================
[CallbackRegistry] registerCallback: timeout= 180000
[ATCoordinatorImpl] timeout ACTIVE
org.apache.kandula.coordinator.TimedOutException
at
org.apache.kandula.coordinator.at.ATCoordinatorImpl.timeout(ATCoordinatorImpl.java:626)
at
org.apache.kandula.coordinator.CallbackRegistry$1.run(CallbackRegistry.java:62)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
catch CoordinatoreInvoke-> Inactivity Timeout Reached, No Response from
the Server
AxisFault
faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: Inactivity Timeout Reached, No Response from the Server
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:Inactivity Timeout Reached, No
Response from the Server
at org.apache.sandesha.client.RMSender.invoke(RMSender.java:125)
at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
===============================================================================================
I used for the client the following client config wsdd file:
===============================================================================================
<!-- a barebone jboss.net/axis client configuration which includes some
basic typemappings related to jboss -->
<deployment name="defaultClientConfig"
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<globalConfiguration>
<parameter name="adminPassword" value="admin"/>
<parameter name="enableNamespacePrefixOptimization" value="true"/>
<parameter name="disablePrettyXML" value="true"/>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="attachments.implementation"
value="org.apache.axis.attachments.AttachmentsImpl"/>
<parameter name="sendXMLDeclaration" value="true"/>
<requestFlow>
<handler
type="java:org.apache.axis.message.addressing.handler.AddressingHandler"
/>
<handler type="java:org.apache.kandula.coordinator.at.TxHandler" />
</requestFlow>
<responseFlow>
<handler
type="java:org.apache.axis.message.addressing.handler.AddressingHandler"
/>
</responseFlow>
</globalConfiguration>
<handler name="RMSender"
type="java:org.apache.sandesha.client.RMSender"/>
<transport name="local"
pivot="java:org.apache.axis.transport.local.LocalSender"/>
<transport name="java"
pivot="java:org.apache.axis.transport.java.JavaSender"/>
<transport name="http"
pivot="java:org.apache.axis.transport.http.HTTPSender"/>
<transport name="RMTransport" pivot="RMSender"/>
<typeMapping
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
qname="wsa:EndpointReference"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
type="java:org.apache.axis.message.addressing.EndpointReferenceType"/>
<typeMapping
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
qname="wsa:ReferencePropertiesType"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
type="java:org.apache.axis.message.addressing.ReferencePropertiesType"/>
<typeMapping
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
encodingStyle=""
qname="wsa:Address"
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
type="java:org.apache.axis.message.addressing.Address"/>
<typeMapping
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
encodingStyle=""
qname="wsa:PortType"
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
type="java:org.apache.axis.message.addressing.PortType" />
<typeMapping
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
deserializer="org.apache.axis.encoding.ser.SimpleDeserializerFactory"
encodingStyle=""
qname="wsa:ServiceNameType"
serializer="org.apache.axis.encoding.ser.SimpleSerializerFactory"
type="java:org.apache.axis.message.addressing.ServiceNameType" />
</deployment>
=================================================================================================
for the service A the following deploy wsdd file:
==================================================================================================
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Coordinatore" provider="java:RPC">
<parameter name="wsdlTargetNamespace"
value="urn:kandulaClient/Coordinatore"/>
<parameter name="wsdlServiceElement" value="CoordinatoreService"/>
<parameter name="wsdlServicePort" value="Coordinatore"/>
<parameter name="className" value="kandulaClient.Coordinatore"/>
<parameter name="wsdlPortType" value="Coordinatore"/>
<parameter name="typeMappingVersion" value="1.2"/>
<operation name="avvia" qname="operNS:avvia"
xmlns:operNS="urn:kandula/Coordinatore"
soapAction="http://localhost:8080/axis/services/kandulaClient#avvia" >
<parameter qname="in0" type="tns:int"
xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
</operation>
<parameter name="allowedMethods" value="*"/>
</service>
<service name="RMService" provider="Handler">
<requestFlow>
<handler
type="java:org.apache.sandesha.ws.rm.handlers.RMServerRequestHandler"></handler>
<handler
type="java:org.apache.axis.message.addressing.handler.AddressingHandler"></handler>
</requestFlow>
<parameter name="handlerClass"
value="org.apache.sandesha.ws.rm.providers.RMClientProvider"/>
<parameter name="className"
value="org.apache.sandesha.client.RMService"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="request"/>
</service>
</deployment>
===================================================================================================================0
and for the service B the following:
===========================================================================================================
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Servizio1" provider="Handler">
<parameter name="wsdlTargetNamespace"
value="urn:kandulaServizio1/Servizio1"/>
<parameter name="wsdlServiceElement" value="Servizio1Service"/>
<parameter name="wsdlServicePort" value="Servizio1"/>
<parameter name="className" value="kandulaServizio1.Servizio1"/>
<parameter name="wsdlPortType" value="Servizio"/>
<parameter name="typeMappingVersion" value="1.2"/>
<operation name="somma" qname="operNS:somma"
xmlns:operNS="urn:kandula/Coordinatore" returnQName="sommaReturn"
returnType="rtns:int" xmlns:rtns="http://www.w3.org/2001/XMLSchema"
soapAction="http://localhost:8080/axis/services/kandulaServizio1#somma" >
<parameter qname="in0" type="tns:int"
xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
<parameter qname="in1" type="tns:int"
xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
</operation>
<parameter name="allowedMethods" value="*"/>
<requestFlow>
<handler
type="java:org.apache.sandesha.ws.rm.handlers.RMServerRequestHandler"></handler>
<handler
type="java:org.apache.axis.message.addressing.handler.AddressingHandler"></handler>
</requestFlow>
<parameter name="handlerClass"
value="org.apache.sandesha.ws.rm.providers.RMProvider"/>
</service>
</deployment>
=================================================================================================================
What's wrong ?
Thanks Valerio
----- Original Message -----
From: "Hannes Erven" <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
To: "Valerio Vianello" <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
Cc: <[email protected] <mailto:[email protected]>>
Sent: Monday, July 17, 2006 12:58 PM
Subject: Re: kandula and sandesha
> Hi Valerio,
>
>
>> [CallbackRegistry] registerCallback: timeout= 180000
>> [ATCoordinatorImpl] timeout ACTIVE
>> org.apache.kandula.coordinator.TimedOutException
>> at
>>
org.apache.kandula.coordinator.at.ATCoordinatorImpl.timeout(ATCoordinatorImpl.java:626)
>>
>> at
>>
org.apache.kandula.coordinator.CallbackRegistry$1.run(CallbackRegistry.java:62)
>
>
> Can you please explain to us what your service is doing? It seems that
> the connection to the kandula coordinator is OK.
>
>
> -hannes
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
>
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]