axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maicon Stihler" <stih...@gmail.com>
Subject Re: [Axis2] Calling a service from another service
Date Sat, 01 Dec 2007 01:22:35 GMT
Well, even though I use the muse API to craft a notification message,
I don't use it to invoke the remote service. If I try to send the
notification message from a command line client it works fine, that's
why I have a feeling that I'm doing something wrong in the way I call
the service inside this first service.

I'll make some tests with other kinds of services to make sure that
the problem isn't with Axis.

thank you

2007/11/30, Martin Gainty <mgainty@hotmail.com>:
> Hi Maicon
>
> This is a muse webapp ..did you contact the muse folks at
> muse-user-subscribe@ws.apache.org
>
> ?
> M--
> ----- Original Message -----
> From: "Maicon Stihler" <stihler@gmail.com>
> To: <axis-user@ws.apache.org>
> Sent: Friday, November 30, 2007 4:50 PM
> Subject: Re: [Axis2] Calling a service from another service
>
>
> > 2007/11/30, Martin Gainty <mgainty@hotmail.com>:
> > > Hi Maicon-
> > >
> > > 1)can we see the client code.. in particular the part which specifies
> the
> > > Action
> > The code is on the bottom of the email.
> >
> > > 2)Is there a reason why the client is not initiating all of the web
> service
> > > queries
> > I want the first service to notify this second service when being
> > invoked, this action must be transparent to the user because it's not
> > related to the application logic.
> >
> > Best regards,
> > Maicon
> >
> > obs: the code is really ugly, I just started to play with java+soap.
> >
> > This is the service that is called by the user, this service then
> > crafts a notification message and sends it to a second service.
> >
> > ----- code ----
> >
> > import org.apache.axiom.om.OMAbstractFactory;
> > import org.apache.axiom.om.OMElement;
> > import org.apache.axiom.om.OMFactory;
> > import org.apache.axiom.om.OMNamespace;
> > import org.apache.axis2.Constants;
> > import org.apache.axis2.addressing.EndpointReference;
> > import org.apache.axis2.client.Options;
> > import org.apache.axis2.client.ServiceClient;
> > import org.apache.axis2.util.XMLUtils;
> >
> > import org.apache.muse.ws.notification.impl.SimpleNotificationMessage;
> > import org.apache.muse.ws.notification.NotificationMessage;
> > import org.apache.muse.util.xml.XmlUtils;
> > import org.w3c.dom.Element;
> > import org.apache.axiom.soap.SOAPFault;
> >
> >
> >
> > import javax.xml.namespace.QName;
> >
> > public class PEP {
> >
> >     private static String PREFIX = "tns";
> >     private static String NAMESPACE_URI =
> "http://org.stihler.vo/guardian/wsn";
> >     private static QName TOPIC = new QName(NAMESPACE_URI, "PEP", PREFIX);
> >     private static QName messageName = new QName(NAMESPACE_URI,
> > "PEPNotification", PREFIX);
> >
> >     public OMElement invoke(OMElement element) throws Exception {
> >        try {
> >
> >         element.build();
> >         element.detach();
> >
> >         OMElement msg = createNotification("This is a simple
> > Notification Message");
> >
> >         element.addChild(publish(msg));
> >
> >         return element;
> >
> >       } catch (org.apache.axis2.AxisFault e) {
> >                 java.io.BufferedWriter bw =
> >                 new java.io.BufferedWriter(new
> > java.io.FileWriter("/tmp/erros-axis.xml"));
> >                 bw.write(e.getMessage());
> >                 bw.close();
> >                 return element;
> >       }
> >     }
> >
> >     private OMElement createNotification(String content) {
> >         try {
> >                 org.apache.muse.ws.addressing.EndpointReference
> EventBoxEPR =
> >                 new org.apache.muse.ws.addressing.EndpointReference(
> >                 new
> > java.net.URI("http://localhost:8080/axis2/services/EventBox"));
> >
> >                 org.apache.muse.ws.addressing.EndpointReference
> ProducerEPR =
> >                 new org.apache.muse.ws.addressing.EndpointReference(
> >                 new
> java.net.URI("http://localhost:8080/axis2/services/PEP"));
> >
> >
> >                 NotificationMessage msg = new SimpleNotificationMessage();
> >                 msg.setSubscriptionReference(EventBoxEPR);
> >                 msg.setProducerReference(ProducerEPR);
> >                 msg.setTopic(TOPIC);
> >
> >                 Element payload = XmlUtils.createElement(messageName,
> >                         content);
> >                 msg.addMessageContent(payload);
> >                 return XMLUtils.toOM( msg.toXML() );
> >         }
> >         catch(Exception e) {
> >                 return null;
> >         }
> >     }
> >
> >     private OMElement publish(OMElement msg) throws Exception{
> >             EndpointReference EventBoxEPR =
> >                 new EndpointReference(
> >                     "http://localhost:8080/axis2/services/EventBox");
> >
> >             Options options = new Options();
> >             options.setTo(EventBoxEPR);
> >             options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
> >             ServiceClient sender = new ServiceClient();
> >             sender.setOptions(options);
> >             OMElement rq = makeRequest(msg);
> >             sender.sendReceive(rq);
> >             return msg;
> >     }
> >
> >     private static OMElement makeRequest(OMElement payload) {
> >         try {
> >                 OMFactory fac = OMAbstractFactory.getOMFactory();
> >                 OMNamespace omNs = fac.createOMNamespace(
> >                           "http://org.stihler.vo/EventBox", "omNs");
> >                 OMElement method = fac.createOMElement("publish", omNs);
> >                 method.addChild(payload);
> >                 return method;
> >         }
> >         catch(Exception e) {
> >                 return null;
> >         }
> >     }
> >
> > }
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

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


Mime
View raw message