synapse-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khld zarig <k.za...@hotmail.com>
Subject calling external ws from synapse
Date Tue, 22 Apr 2008 11:01:17 GMT
Hi all, i deployed synapse.war in jbossAS 4.2.1, it works fine and intercepts all SOAP requests
messages at the client side. 
however, what i am trying to do is that:
1: in synapse and before the client request released to its destination, i need to call external
web service to get some information
2:  then and depending of these information ( the External web service return string ) 
i can take a decision which one of these (modify or delay the client request ) then let it
go to its final destination
 
 i tried to have my own mediator which its job is to call the mentioned External web Service,
but synapse throws an Exception:
 
11:21:01,615 INFO  [STDOUT] 2008-04-22 11:21:01,615 [128.240.150.106-morralee] [HttpCoreNIOSender]
 INFO HttpCoreNIOSender Sender Shutdown
11:21:01,631 INFO  [STDOUT] 2008-04-22 11:21:01,631 [-] [Finalizer]  INFO HttpCoreNIOSender
Sender shut down11:21:01,631 INFO  [STDOUT] 2008-04-22 11:21:01,631 [128.240.150.106-morralee]
[HttpCoreNIOSender]  INFO HttpCoreNIOSender Sender Shutdown
11:21:01,631 INFO  [STDOUT] 2008-04-22 11:21:01,631 [-] [Finalizer]  INFO HttpCoreNIOSender
Sender shut down11:21:01,662 INFO  [STDOUT] 2008-04-22 11:21:01,646 [128.240.150.106-morralee]
[HttpServerWorker-1]  INFO TimeoutHandler This engine willexpire all callbacks after : 86400
seconds, irrespective of the timeout action, after the specified or optional timeout11:21:01,662
INFO  [STDOUT] 2008-04-22 11:21:01,662 [128.240.150.106-morralee] [HttpServerWorker-1] ERROR
Axis2Sender Unexpected error during sending message outorg.apache.axis2.AxisFault: Address
information does not exist in the Endpoint Reference (EPR).The system cannot infer the transport
mechanism.        at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:65)
       at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:118)
       at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)      
 at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:250)
       at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:55)        at
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:200)
       at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97)
       at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:60)
       at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:122)
       at org.apache.synapse.mediators.MediatorFaultHandler.onFault(MediatorFaultHandler.java:79)
       at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:94)        at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:95)
       at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
       at org.apache.synapse.transport.nhttp.ServerWorker.processPost(ServerWorker.java:218)
       at org.apache.synapse.transport.nhttp.ServerWorker.run(ServerWorker.java:182)     
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) 
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) 
 
 
this is synapse.xml:
 

<?xml version="1.0" encoding="UTF-8"?>
<syn:definitions xmlns:syn="http://ws.apache.org/ns/synapse">
   <syn:sequence name="fault">
     <syn:makefault>
        <syn:code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
        <syn:reason value="Mediation failed."/>
     </syn:makefault>
     <syn:send/>
  </syn:sequence>
<syn:sequence name="main" onError="fault">
<syn:in>
<syn:class name="samples.mediators.test1"/>
<syn:send>
<syn:endpoint>
<syn:address uri="http://localhost:8008/ProviderMessage"/>
</syn:endpoint>
</syn:send> 
</syn:in>
<syn:out>
<syn:send/>
</syn:out>
</syn:sequence>
</syn:definitions>
 
this is my mediator:
 
package samples.mediators;
import org.apache.synapse.MessageContext;import org.apache.synapse.Mediator;import org.apache.synapse.core.axis2.Axis2MessageContext;import
org.apache.axis2.Constants;import org.apache.axis2.AxisFault;import org.apache.axis2.addressing.EndpointReference;import
org.apache.axis2.client.Options;import org.apache.axis2.rpc.client.RPCServiceClient;import
javax.xml.namespace.QName;public class test1 implements Mediator{
    public boolean mediate(MessageContext msgContext)    {        callExternalWS();      
 return true;    }
    public String getType() {        return null;  //To change body of implemented methods
use File | Settings | File Templates.    }
    public int getTraceState() {        return 0;  //To change body of implemented methods
use File | Settings | File Templates.    }
    public void setTraceState(int i) {        //To change body of implemented methods use
File | Settings | File Templates.    }
    public  void callExternalWS()    {
        RPCServiceClient serviceClient = null;        try        {            serviceClient
= new RPCServiceClient();
        }        catch (AxisFault axisFault)        {
            axisFault.printStackTrace();        }
        Options options = serviceClient.getOptions();
        EndpointReference targetEPR = new EndpointReference("http://localhost:8010/ProviderMessage");
       options.setTo(targetEPR);        QName opAddEntry = new QName("http://agents.services/",
"Emulate");
        String name = "Hi from Client ...!";        String name2 = "Hi from Client ...!";
        Object[] opFindEntryArgs = new Object[] { name,name2 };        Class[] returnTypes
= new Class[] { String.class };        Object[] response = new Object[0];        try     
  {
//the problem happening here            response = serviceClient.invokeBlocking(opAddEntry,opFindEntryArgs,
returnTypes);        }        catch (AxisFault axisFault)        {            axisFault.printStackTrace();
       }
        String result = (String) response[0];               System.out.println("Result of
calling External WS :        " + result);    }
}
 
 
 
by the way, i know callout mediator, however I think it can not satisfy my requirements. 
 
any help. 
 
K.zarig
 



_________________________________________________________________
Bag extra points with the Walkers Brit Trip Game 
http://www.walkersbrittrips.co.uk/game
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message