synapse-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khld zarig <>
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 [] [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 []
[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 []
[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 [] [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(
       at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(
       at org.apache.axis2.client.OperationClient.execute(      
 at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(
       at org.apache.synapse.core.axis2.Axis2Sender.sendOn(        at
       at org.apache.synapse.mediators.builtin.SendMediator.mediate(
       at org.apache.synapse.mediators.AbstractListMediator.mediate(
       at org.apache.synapse.mediators.base.SequenceMediator.mediate(
       at org.apache.synapse.mediators.MediatorFaultHandler.onFault(
       at org.apache.synapse.FaultHandler.handleFault(        at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(
       at org.apache.axis2.engine.AxisEngine.receive(        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(
       at org.apache.synapse.transport.nhttp.ServerWorker.processPost(
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask( 
      at java.util.concurrent.ThreadPoolExecutor$ 
this is synapse.xml:

<?xml version="1.0" encoding="UTF-8"?>
<syn:definitions xmlns:syn="">
   <syn:sequence name="fault">
        <syn:code xmlns:tns="" value="tns:Receiver"/>
        <syn:reason value="Mediation failed."/>
<syn:sequence name="main" onError="fault">
<syn:class name="samples.mediators.test1"/>
<syn:address uri="http://localhost:8008/ProviderMessage"/>
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("",
        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. 

Bag extra points with the Walkers Brit Trip Game
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message