Below is the code. No the Accepts method is not called.
package org.mitre.localhost.track_consumer;
import java.util.Collection;
import java.util.Iterator;
import javax.xml.namespace.QName;
import org.apache.muse.core.AbstractCapability;
import org.apache.muse.ws.addressing.soap.SoapFault;
import org.apache.muse.ws.notification.NotificationConsumer;
import org.apache.muse.ws.notification.NotificationMessage;
import org.apache.muse.ws.notification.NotificationMessageListener;
import org.apache.muse.ws.notification.WsnConstants;
import org.mitre.trajvisual.util.comm.client.XmlClient;
import org.w3c.dom.Element;
public class MyCapability extends AbstractCapability implements
IMyCapability, NotificationMessageListener
{
private XmlClient mClient;
private TrackClient mTrackClient = new TrackClient();
public void initializeCompleted() throws SoapFault{
super.initializeCompleted();
getLog().info("register as a message listener for the Consumer
"+WsnConstants.CONSUMER_URI);
NotificationConsumer wsn =
(NotificationConsumer)getResource().getCapability(WsnConstants.CONSUMER
_URI);
wsn.addMessageListener(this);
}
public void register(String hostname, int portNo) throws
Exception {
mTrackClient.connect();
mClient = new XmlClient(hostname, portNo);
}
public boolean accepts(NotificationMessage message)
{
getLog().info("ACCEPTS BEING CALLED");
return true;
}
public void process(NotificationMessage message)
{
getLog().info("Process Notification Message Consumer
Received!!!!!!!!!!!!!!!\n" + message);
Collection c = message.getMessageContentNames();
Iterator i = c.iterator();
while(i.hasNext()){
Element element = message.getMessageContent((QName)i.next());
// getLog().info("Element "+element);
// getLog().info("xml elmenet "+element.getNodeName());
String text = element.getTextContent();
// getLog().info("size "+text.length());
// getLog().info("text "+text);
mClient.send(text);
}
}
}
-----Original Message-----
From: Daniel Jemiolo [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 27, 2007 2:22 PM
To: [email protected]
Subject: RE: Publisher Consumer
I'm not sure your WSDL is the problem - sounds like the code to hook up
the message listener might be off. Three things:
1. You say you overrode the initialization methods in
SimpleNotificationConsumer... how did you change them? Can you post the
code? Normally, you shouldn't need to alter the NotificationConsumer
capability itself, just add listeners.
2. Can you show the capability code for setting up the listener?
3. Is your accepts() method being called?
"Callner, David A." <[EMAIL PROTECTED]> wrote on 03/27/2007 09:35:08
AM:
> Below is a wsdl that I've added a register message. I want clients
> that are not web applications to use the proxy genereated code of
this
> consumer to be able to register a hostname and portno. I can
generate
> the code and when I deploy the consumer war file everything seems to
> work fine except that my generated code does not get called. I've
> implemented the NotificationMessageListener just like the
wsn-consumer
> example but the process method is never called. I set the stack trace
> and I'm able to see that the NotificationConsumer has been
initialized
> and initializedCompleted but I've overloaded those methods and they
are
> not called. When I publish data from the producer I can see it
produce
> and I see that this NotificationConsumer receives the callbacks in
the
> SOAP Trace, but MyCapability methods are never called. Can you tell
my
> looking at my wsdl what I might have done wrong?
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <wsdl:definitions name="TrackConsumer"
> targetNamespace="http://localhost.mitre.org/track-consumer"
> xmlns:tns="http://localhost.mitre.org/track-consumer"
> xmlns:wsa="http://www.w3.org/2005/08/addressing"
> xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
> xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:wsdl-soap="http://schemas.xmlsoap.org/wsdl/soap/">
>
> <wsdl:types>
> <xsd:schema>
> <xsd:import
> namespace="http://docs.oasis-open.org/wsn/b-2"
> schemaLocation="WS-BaseNotification-1_3.xsd"/>
> </xsd:schema>
>
> <xsd:schema
> elementFormDefault="qualified"
> targetNamespace="http://localhost.mitre.org/track-consumer">
> <xsd:element name="Register">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="hostname" type="xsd:string"/>
> <xsd:element name="portNo"
> type="xsd:integer"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
> </wsdl:types>
>
> <wsdl:message name="Notify">
> <wsdl:part name="Notify" element="wsnt:Notify"/>
> </wsdl:message>
>
> <wsdl:message name="RegisterRequest">
> <wsdl:part name="RegisterRequest" element="tns:Register" />
> </wsdl:message>
>
> <wsdl:portType name="NotificationConsumer">
> <wsdl:operation name="Notify">
> <wsdl:input
>
>
wsa:Action="http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/No
> tifyRequest"
> message="tns:Notify" />
> </wsdl:operation>
> <wsdl:operation name="Register">
> <wsdl:input
> wsa:Action="http://localhost.mitre.org/track-consumer/Register"
> name="RegisterRequest"
> message="tns:RegisterRequest" />
> </wsdl:operation>
>
> </wsdl:portType>
>
> <wsdl:binding name="Binding" type="tns:NotificationConsumer">
> <wsdl-soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
> <wsdl:operation name="Notify">
> <wsdl-soap:operation/>
> <wsdl:input>
> <wsdl-soap:body
>
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> use="literal"/>
> </wsdl:input>
> </wsdl:operation>
> <wsdl:operation name="Register">
> <wsdl-soap:operation soapAction="Register" />
> <wsdl:input>
> <wsdl-soap:body
> use="encoded"
>
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
> </wsdl:input>
> </wsdl:operation>
> </wsdl:binding>
>
>
> <wsdl:service name="TrackConsumerService">
> <wsdl:port binding="tns:Binding" name="Port">
> <wsdl-soap:address
>
>
location="http://localhost.mitre.org/track-consumer/services/TrackConsu
> mer"/>
> </wsdl:port>
> </wsdl:service>
>
> </wsdl:definitions>
>
> -----Original Message-----
> From: Daniel Jemiolo [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 23, 2007 3:57 PM
> To: [email protected]
> Subject: RE: Publisher Consumer
>
> I took the two sections of WSDL (what I sent + Andrew's binding and
> service) and pasted them into a .wsdl file. After I'd added a few
> prefix
> mappings to the root element, the resulting WSDL doc was this:
>
> <wsdl:definitions name="MyConsumer"
> targetNamespace="http://www.example.com/my/consumer"
> xmlns:tns="http://www.example.com/my/consumer"
> xmlns:wsa="http://www.w3.org/2005/08/addressing"
> xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
> xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:wsdl-soap="http://schemas.xmlsoap.org/wsdl/soap/">
>
> <wsdl:types>
> <xsd:schema>
> <xsd:import
> namespace="http://docs.oasis-open.org/wsn/b-2"
> schemaLocation="WS-BaseNotification-1_3.xsd"/>
> </xsd:schema>
> </wsdl:types>
>
> <wsdl:message name="Notify">
> <wsdl:part name="Notify" element="wsnt:Notify"/>
> </wsdl:message>
>
> <wsdl:portType name="NotificationConsumer">
> <wsdl:operation name="Notify">
> <wsdl:input
>
wsa:Action="http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/No
> tifyRequest"
> message="tns:Notify" />
> </wsdl:operation>
> </wsdl:portType>
>
> <wsdl:binding name="Binding" type="tns:NotificationConsumer">
> <wsdl-soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http"/>
> <wsdl:operation name="Notify">
> <wsdl-soap:operation/>
> <wsdl:input>
> <wsdl-soap:body
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> use="literal"/>
> </wsdl:input>
> </wsdl:operation>
> </wsdl:binding>
> <wsdl:service name="Service">
> <wsdl:port binding="tns:Binding" name="Port">
> <wsdl-soap:address
> location="http://127.0.0.1/consumer/services/MyConsumer"/>
> </wsdl:port>
> </wsdl:service>
>
> </wsdl:definitions>
>
>
>
> I ran the latest wsdl2java on this wsdl like so:
>
> > wsdl2java.bat -wsdl MyConsumer.wsdl -j2ee mini
>
>
> I get the warning message you describe, but that warning is just to
let
>
> you know that there is no WSRP doc, since sometimes people *do*
specify
> a
> WSRP doc, but they get the XML wrong and it doesn't get located.
> Anyway,
> the resulting muse.xml file that was generated in
> WebContent/WEB-INF/classes has the following entry:
>
> <desc:capability xmlns:desc="http://ws.apache.org/muse/descriptor">
>
>
<desc:capability-uri>http://docs.oasis-open.org/wsn/bw-2/NotificationCo
> nsumer</desc:capability-uri>
>
>
<desc:java-capability-class>org.apache.muse.ws.notification.impl.Simple
> NotificationConsumer</desc:java-capability-class>
> </desc:capability>
>
>
> Which loads the WSN NotificationConsumer capability for the resource
> type.
> It's up to you to add message listener logic like that in the
> wsn-consumer
> sample (see ConsumerCapabilityImpl.java). If you have a capability
with
>
> properties or operations, wsdl2java will generate code for it, and
you
> can
> include your message listener hookup in those classes; if not, you
need
> to
> write your own classes and add a <capability/> entry to muse.xml
> explicitly.
>
> An interesting feature idea might be to generate a
> no-properties-or-operations capability for users that have WSN Notify
> in
> their WSDLs. This capability would have a name indicating that it was
> just
> for setting up the logic needed to respond to incoming notifications.
> If
> anyone else thinks that's a good idea, please create a JIRA item for
it
> so
> we can discuss.
>
> Dan
>
>
>
>
>
> "Callner, David A." <[EMAIL PROTECTED]> wrote on 03/23/2007 03:38:12
> PM:
>
> > Andrew,
> > Thanks, but no code gets generated. I get a Warning that
> NoWSRPSchema.
> > I've played around with this wsdl a lot trying to get it to work.
If
> I
> > do create a wsrf-rp:ResourceProperties="AnythingDefined" in the
> > portType then I get generated code, but that generated code is the
> same
> > as the Producer code and I want the Consumer Code.
> >
> > -----Original Message-----
> > From: Andrew Eberbach [mailto:[EMAIL PROTECTED]
> > Sent: Friday, March 23, 2007 3:10 PM
> > To: [email protected]
> > Subject: RE: Publisher Consumer
> >
> > Hi,
> >
> > Your WSDL needs to have a binding and service section. Here they
are:
> >
> > <wsdl:binding name="Binding" type="tns:NotificationConsumer">
> > <wsdl-soap:binding style="document"
> > transport="http://schemas.xmlsoap.org/soap/http"/>
> > <wsdl:operation name="Notify">
> > <wsdl-soap:operation/>
> > <wsdl:input>
> > <wsdl-soap:body
> > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > use="literal"/>
> > </wsdl:input>
> > </wsdl:operation>
> > </wsdl:binding>
> > <wsdl:service name="Service">
> > <wsdl:port binding="tns:Binding" name="Port">
> > <wsdl-soap:address
> > location="http://127.0.0.1/notification/services/notification"/>
> > </wsdl:port>
> > </wsdl:service>
> >
> >
> > Thanks,
> > Andrew
> >
> > Andrew Eberbach
> > Autonomic Computing
> > (919) 254-2645
> > T/L: 444-2645
> > [EMAIL PROTECTED]
> >
> >
> >
> > "Callner, David A." <[EMAIL PROTECTED]>
> > 03/23/2007 01:37 PM
> > Please respond to
> > [email protected]
> >
> >
> > To
> > <[email protected]>
> > cc
> >
> > Subject
> > RE: Publisher Consumer
> >
> >
> >
> >
> >
> >
> > The following wsdl throws the exception below. I've tried it this
> way
> > before and got the exception below then I tried adding a
ServiceName,
> > etc and I would get another exception. What do I need to have a
> > Consumer???
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <wsdl:definitions
> > targetNamespace="http://localhost.mitre.org/track-consumer"
> >
> xmlns:tns="http://localhost.mitre.org/track-consumer"
> > xmlns="http://schemas.xmlsoap.org/wsdl/"
> > xmlns:wsa="http://www.w3.org/2005/08/addressing"
> > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> >
> > xmlns:wsdl-soap="http://schemas.xmlsoap.org/wsdl/soap/"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2"
> > xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
> > name="Consumer">
> > <wsdl:types>
> > <xsd:schema
> > elementFormDefault="qualified"
> >
> > targetNamespace="http://docs.oasis-open.org/wsn/b-2">
> > <xsd:include
> > schemaLocation="WS-BaseNotification-1_3.xsd" />
> > </xsd:schema>
> > </wsdl:types>
> > <!-- ==========
NotificationProducer::GetCurrentMessage
>
> ===========
GetCurrentMessage(topicExpression)
> returns: a
> NotificationMessage (xsd:any)
-->
> > <wsdl:message name="Notify">
> > <wsdl:part name="Notify" element="wsnt:Notify"/>
> > </wsdl:message>
> >
> > <wsdl:portType name="NotificationConsumer">
> > <wsdl:operation name="Notify">
> > <wsdl:input
> >
>
wsa:Action="http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/No
> > tifyRequest"
> >
> > message="wsntw:Notify"
> > />
> >
> > </wsdl:operation>
> > </wsdl:portType>
> >
> > </wsdl:definitions>
> >
> > java.lang.RuntimeException: [ID = 'OneServicePerWSDL'] The resource
> > inspector
> > can only process WSDLs with one service element.
> > at
> >
>
org.apache.muse.tools.inspector.ResourceInspector.getPortType(ResourceI
> > nspector.java:619)
> > at
> >
>
org.apache.muse.tools.inspector.ResourceInspector.run(ResourceInspector
> > .java:839)
> > at
> >
>
org.apache.muse.tools.generator.analyzer.SimpleAnalyzer.inspect(SimpleA
> > nalyzer.java:392)
> > at
> >
>
org.apache.muse.tools.generator.analyzer.SimpleAnalyzer.analyze(SimpleA
> > nalyzer.java:338)
> > at
> > org.apache.muse.tools.generator.Wsdl2Java.run(Wsdl2Java.java:143)
> > at
> > org.apache.muse.tools.generator.Wsdl2Java.main(Wsdl2Java.java:260)
> >
> > SEVERE: [ID = 'CodeGenFailed'] Code generation failed, see the
> > exception information below.
> >
> > An exception was caught: [ID = 'OneServicePerWSDL'] The resource
> > inspector can only process WSDLs with one service
> > element.
> >
> >
> >
> >
> > -----Original Message-----
> > From: Daniel Jemiolo [mailto:[EMAIL PROTECTED]
> > Sent: Friday, March 23, 2007 11:41 AM
> > To: [email protected]
> > Subject: RE: Publisher Consumer
> >
> > The WSDL fragment below represents all of the code you need to
> provide
> > for
> > WSN Notify, save for the WSDL <binding/>. It's the same XML from
> > WS-BaseNotification-1_3.wsdl, which is used in the wsn-consumer
> > project.
> >
> > <wsdl:types>
> > <xsd:schema>
> > <xsd:import
> > namespace="http://docs.oasis-open.org/wsn/b-2"
> > schemaLocation="WS-BaseNotification-1_3.xsd"/>
> > </xsd:schema>
> > </wsdl:types>
> >
> > <wsdl:message name="Notify">
> > <wsdl:part name="Notify" element="wsnt:Notify"/>
> > </wsdl:message>
> >
> > <wsdl:portType name="NotificationConsumer">
> > <wsdl:operation name="Notify">
> > <wsdl:input
> >
> >
>
wsa:Action="http://docs.oasis-open.org/wsn/bw-2/NotificationConsumer/No
> > tifyRequest"
> >
> > message="wsntw:Notify" />
> > </wsdl:operation>
> > </wsdl:portType>
> >
> >
> >
> > "Callner, David A." <[EMAIL PROTECTED]> wrote on 03/23/2007
11:03:44
> > AM:
> >
> > > Dan,
> > > If you could just give me the wsdl you used to create the
> > wsn-consumer
> > > I should be able to figure it out from there. Why isn't that
> > > distributed in the examples?
> > >
> > > -----Original Message-----
> > > From: Daniel Jemiolo [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, March 23, 2007 11:00 AM
> > > To: [email protected]
> > > Subject: RE: Publisher Consumer
> > >
> > > Your attachments didn't come through - can create a JIRA item and
> > > attach
> > > the files there?
> > >
> > > Thanks,
> > > Dan
> > >
> > >
> > >
> > > "Callner, David A." <[EMAIL PROTECTED]> wrote on 03/23/2007
> 10:37:25
> > > AM:
> > >
> > > > This doesn't seem to work for me. I've attached my files.
I've
> > > > stripped them down to just have the Notify Consumer info that
you
> > > > describe below but when I can get it to create the code it only
> > > creates
> > > > code like that of the producer.
> > > >
> > > > -----Original Message-----
> > > > From: Daniel Jemiolo [mailto:[EMAIL PROTECTED]
> > > > Sent: Thursday, March 22, 2007 10:20 AM
> > > > To: [email protected]
> > > > Subject: Re: Publisher Consumer
> > > >
> > > > The wsn-consumer resource uses the NotificationConsumer
portType
> in
> >
> > > > WS-BaseNotification-1_3.wsdl file - this is mapped in muse.xml,
> > under
> > > > the
> > > > <resource-type><wsdl> element. The sample has nothing but WSN
> > > > NotificationConsumer in its interface.
> > > >
> > > > All you need to do to add NotiifcationConsumer to your app is
to
> > add
> > > > the
> > > > contents of NotificationConsumer portType (which is just the
> Notify
> >
> > > > operation) to your own WSDL's portType. Be sure to include the
> > > > <message/>
> > > > and XSD definition for Notify, just as
> WS-BaseNotification-1_3.wsdl
> > > > does.
> > > > When you run wsdl2java, it will notice the WSN Notify operation
> and
> > > add
> > > >
> > > > Muse's NOtificationConsumer capabilty to your resource
> definition.
> > > >
> > > > Dan
> > > >
> > > >
> > > >
> > > > "Callner, David A." <[EMAIL PROTECTED]> wrote on 03/22/2007
> > 07:45:59
> > > > AM:
> > > >
> > > > > There is an example of the wsn-producer and wsn-consumer. I
> > want
> > > to
> > > > > deploy a web service that is a producer and I want clients to
> be
> > > able
> > > > > to create wsn-consumer's on there own. Could somebody
explain
> to
> > > me
> > > > > how the wsn-consumer was created? The wsdl for the
> wsn-producer
> > > does
> > > > > not show in a browser and I see no way to generate the code
> from
> > > the
> > > > > wsdl from the wsn-producer. I can generate the code for the
> > > > > wsn-producer from the wsdl, but how does one create a
consumer.
> > Is
> > > > > everybody expected to start with a wsn-consumer and hack up
> there
> > > own
> > > > > wsn-consumers? This obviously can't be the case but I see no
> > other
> > > > > way.
> > > > >
> > > > > Thanks for your help.
> > > > >
> > > > > David Callner
> > > > > Senior Software Systems Engineer
> > > > > The MITRE Corporation
> > > > > Center for Advanced Aviation System Development
> > > > > 7515 Colshire Dr.
> > > > > McLean, VA. 22102
> > > > > [EMAIL PROTECTED]
> > > > > 703.983.6431 (work)
> > > > >
> > > > >
> > > > >
> > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >
> > > >
> > > >
> > > >
> >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > > >
> >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]