2007/11/30, Martin Gainty <[EMAIL PROTECTED]>: > 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]