You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Leandro Sales <le...@enovar.com.br> on 2007/05/24 15:38:55 UTC

wsn2005 outside JBI bus

HI,

   I'm trying to use wsn2005 but i'm not finding any docs to help me on 
it. After hard work I could create a NotificationBroeker and Subscribe 
to a topic  but I can't discover how to send/receive notification 
to/from this topic. This code above is what i've done... Canybody can 
help me on my next steps?

Thanx anyway,

Leandro

try{
                 
            URL url = new URL("http://localhost:8192/Broker/main.wsdl");
           
            Service s = Service.create(url,new 
QName("http://servicemix.org/wsnotification","NotificationBroker"));
            NotificationBroker nb = s.getPort(new 
QName("http://servicemix.org/wsnotification","http-binding"),NotificationBroker.class);
           
           
            //Subscribe
            SubscribeFactoryBean subscribeFactoryBean = new 
SubscribeFactoryBean();
            subscribeFactoryBean.setTopic("meuTopico");           
            Subscribe subscribe = 
(Subscribe)subscribeFactoryBean.getObject();           
            EndpointReferenceType consumer = new EndpointReferenceType();
           
            consumer.setAddress(new AttributedURIType());
            
consumer.getAddress().setValue("http://servicemix.org/wsnotification/NotificationBroker/http-binding");
            subscribe.setConsumerReference(consumer);
            SubscribeResponse subscribeResponse = nb.subscribe(subscribe);
           
           
            //Register Publisher
            /*RegisterPublisherFactoryBean registerPublisherFactoryBean 
= new RegisterPublisherFactoryBean();
            registerPublisherFactoryBean.setTopic("meuTopico");
            RegisterPublisher rp = 
(RegisterPublisher)registerPublisherFactoryBean.getObject();
           
            EndpointReferenceType registerPublisherEndpoint = new 
EndpointReferenceType();           
            registerPublisherEndpoint.setAddress(new AttributedURIType());
            
registerPublisherEndpoint.getAddress().setValue("http://servicemix.org/wsnotification/NotificationBroker/http-binding");
           
            rp.setPublisherReference(registerPublisherEndpoint);
            RegisterPublisherResponse registerPublisherResponse = 
nb.registerPublisher(rp);*/
           
           
           
            
System.out.println(subscribeResponse.getSubscriptionReference().getClass().getName());
           
           
           
           
            //Notify
            Notify notify = new Notify();
           
            nb.notify(notify);
           
           
        }
        catch(Exception ex){
            ex.printStackTrace();
        }

Re: wsn2005 outside JBI bus

Posted by Leandro Sales <le...@enovar.com.br>.
Guillaume,

    I Wrote my NotificationConsumerService based on WSDL from 
specification like you suggest and I advanced a lot. But I'm getting an 
error when the NotificationBroker try to send the Notification to
to Service. I'm using GlassFish to host my consumer Service  and I'm 
getting this error on glassfish when the Client is Being invoked (If I 
call the service from the GlassFish test it works correctly) :

Caused by: com.sun.xml.ws.streaming.XMLStreamReaderException: unexpected 
XML tag. expected: {http://schemas.xmlsoap.org/soap/envelope/}Envelope 
but found: {http://docs.oasis-open.org/wsn/b-2}Notify
...

It seems that ServiceMix is not sending the SOAP message correctly...

Could you help me?

Leandro

Guillaume Nodet wrote:
> Not really.  This is just a simplified version of the WSDL.
> If you read the WS-Notification spec quickly, you should have
> the basic understanding needed I guess.
>
> On 5/24/07, Leandro Sales <le...@enovar.com.br> wrote:
>>
>> Guillaume thanks for your answer.
>>
>> I'm tying to use the client API but I can't find so much docs about it
>> even if javadoc. Do you have anything about it?
>>
>> Leandro
>>
>>
>> Guillaume Nodet wrote:
>> > If you are inside the JBI bus, I would advise you to use the client 
>> API
>> > for the WS-Notication component, or to use the lightweight proxy to
>> > publish messages and use a SU to register a consumer.
>> >
>> > If you are inside the JBI bus, as it seems, i would use my favorite 
>> soap
>> > stack to generate java using wsdl->java, and then just use the 
>> generated
>> > classes as explained in the WS-Notification specification.
>> > The key point is that the address of the subscriber is expressed using
>> > a URI
>> > as explained at:
>> >     http://incubator.apache.org/servicemix/uris.html
>> >
>> > So if your subscriber is external to the JBI bus, you need to give the
>> > url
>> > to your service
>> > instead of
>> >  consumer.getAddress().setValue("
>> > 
>> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>> >
>> > Also, if you have not already done so, increase the log level to DEBUG
>> to
>> > see what happens when you
>> > send a notification.
>> >
>> > On 5/24/07, Leandro Sales <le...@enovar.com.br> wrote:
>> >>
>> >> HI,
>> >>
>> >>    I'm trying to use wsn2005 but i'm not finding any docs to help 
>> me on
>> >> it. After hard work I could create a NotificationBroeker and 
>> Subscribe
>> >> to a topic  but I can't discover how to send/receive notification
>> >> to/from this topic. This code above is what i've done... Canybody can
>> >> help me on my next steps?
>> >>
>> >> Thanx anyway,
>> >>
>> >> Leandro
>> >>
>> >> try{
>> >>
>> >>             URL url = new URL("http://localhost:8192/Broker/main.wsdl
>> ");
>> >>
>> >>             Service s = Service.create(url,new
>> >> QName("http://servicemix.org/wsnotification","NotificationBroker"));
>> >>             NotificationBroker nb = s.getPort(new
>> >> QName("http://servicemix.org/wsnotification","http-binding"),
>> >> NotificationBroker.class);
>> >>
>> >>
>> >>             //Subscribe
>> >>             SubscribeFactoryBean subscribeFactoryBean = new
>> >> SubscribeFactoryBean();
>> >>             subscribeFactoryBean.setTopic("meuTopico");
>> >>             Subscribe subscribe =
>> >> (Subscribe)subscribeFactoryBean.getObject();
>> >>             EndpointReferenceType consumer = new
>> >> EndpointReferenceType();
>> >>
>> >>             consumer.setAddress(new AttributedURIType());
>> >>
>> >> consumer.getAddress().setValue("
>> >> 
>> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>> >>             subscribe.setConsumerReference(consumer);
>> >>             SubscribeResponse subscribeResponse =
>> >> nb.subscribe(subscribe);
>> >>
>> >>
>> >>             //Register Publisher
>> >>             /*RegisterPublisherFactoryBean 
>> registerPublisherFactoryBean
>> >> = new RegisterPublisherFactoryBean();
>> >>             registerPublisherFactoryBean.setTopic("meuTopico");
>> >>             RegisterPublisher rp =
>> >> (RegisterPublisher)registerPublisherFactoryBean.getObject();
>> >>
>> >>             EndpointReferenceType registerPublisherEndpoint = new
>> >> EndpointReferenceType();
>> >>             registerPublisherEndpoint.setAddress(new
>> >> AttributedURIType());
>> >>
>> >> registerPublisherEndpoint.getAddress().setValue("
>> >> 
>> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>> >>
>> >>             rp.setPublisherReference(registerPublisherEndpoint);
>> >>             RegisterPublisherResponse registerPublisherResponse =
>> >> nb.registerPublisher(rp);*/
>> >>
>> >>
>> >>
>> >>
>> >> System.out.println(subscribeResponse.getSubscriptionReference
>> >> ().getClass().getName());
>> >>
>> >>
>> >>
>> >>
>> >>             //Notify
>> >>             Notify notify = new Notify();
>> >>
>> >>             nb.notify(notify);
>> >>
>> >>
>> >>         }
>> >>         catch(Exception ex){
>> >>             ex.printStackTrace();
>> >>         }
>> >>
>> >
>> >
>> >
>>
>>
>
>


Re: wsn2005 outside JBI bus

Posted by Guillaume Nodet <gn...@gmail.com>.
Not really.  This is just a simplified version of the WSDL.
If you read the WS-Notification spec quickly, you should have
the basic understanding needed I guess.

On 5/24/07, Leandro Sales <le...@enovar.com.br> wrote:
>
> Guillaume thanks for your answer.
>
> I'm tying to use the client API but I can't find so much docs about it
> even if javadoc. Do you have anything about it?
>
> Leandro
>
>
> Guillaume Nodet wrote:
> > If you are inside the JBI bus, I would advise you to use the client API
> > for the WS-Notication component, or to use the lightweight proxy to
> > publish messages and use a SU to register a consumer.
> >
> > If you are inside the JBI bus, as it seems, i would use my favorite soap
> > stack to generate java using wsdl->java, and then just use the generated
> > classes as explained in the WS-Notification specification.
> > The key point is that the address of the subscriber is expressed using
> > a URI
> > as explained at:
> >     http://incubator.apache.org/servicemix/uris.html
> >
> > So if your subscriber is external to the JBI bus, you need to give the
> > url
> > to your service
> > instead of
> >  consumer.getAddress().setValue("
> > http://servicemix.org/wsnotification/NotificationBroker/http-binding");
> >
> > Also, if you have not already done so, increase the log level to DEBUG
> to
> > see what happens when you
> > send a notification.
> >
> > On 5/24/07, Leandro Sales <le...@enovar.com.br> wrote:
> >>
> >> HI,
> >>
> >>    I'm trying to use wsn2005 but i'm not finding any docs to help me on
> >> it. After hard work I could create a NotificationBroeker and Subscribe
> >> to a topic  but I can't discover how to send/receive notification
> >> to/from this topic. This code above is what i've done... Canybody can
> >> help me on my next steps?
> >>
> >> Thanx anyway,
> >>
> >> Leandro
> >>
> >> try{
> >>
> >>             URL url = new URL("http://localhost:8192/Broker/main.wsdl
> ");
> >>
> >>             Service s = Service.create(url,new
> >> QName("http://servicemix.org/wsnotification","NotificationBroker"));
> >>             NotificationBroker nb = s.getPort(new
> >> QName("http://servicemix.org/wsnotification","http-binding"),
> >> NotificationBroker.class);
> >>
> >>
> >>             //Subscribe
> >>             SubscribeFactoryBean subscribeFactoryBean = new
> >> SubscribeFactoryBean();
> >>             subscribeFactoryBean.setTopic("meuTopico");
> >>             Subscribe subscribe =
> >> (Subscribe)subscribeFactoryBean.getObject();
> >>             EndpointReferenceType consumer = new
> >> EndpointReferenceType();
> >>
> >>             consumer.setAddress(new AttributedURIType());
> >>
> >> consumer.getAddress().setValue("
> >> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
> >>             subscribe.setConsumerReference(consumer);
> >>             SubscribeResponse subscribeResponse =
> >> nb.subscribe(subscribe);
> >>
> >>
> >>             //Register Publisher
> >>             /*RegisterPublisherFactoryBean registerPublisherFactoryBean
> >> = new RegisterPublisherFactoryBean();
> >>             registerPublisherFactoryBean.setTopic("meuTopico");
> >>             RegisterPublisher rp =
> >> (RegisterPublisher)registerPublisherFactoryBean.getObject();
> >>
> >>             EndpointReferenceType registerPublisherEndpoint = new
> >> EndpointReferenceType();
> >>             registerPublisherEndpoint.setAddress(new
> >> AttributedURIType());
> >>
> >> registerPublisherEndpoint.getAddress().setValue("
> >> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
> >>
> >>             rp.setPublisherReference(registerPublisherEndpoint);
> >>             RegisterPublisherResponse registerPublisherResponse =
> >> nb.registerPublisher(rp);*/
> >>
> >>
> >>
> >>
> >> System.out.println(subscribeResponse.getSubscriptionReference
> >> ().getClass().getName());
> >>
> >>
> >>
> >>
> >>             //Notify
> >>             Notify notify = new Notify();
> >>
> >>             nb.notify(notify);
> >>
> >>
> >>         }
> >>         catch(Exception ex){
> >>             ex.printStackTrace();
> >>         }
> >>
> >
> >
> >
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Principal Engineer, IONA
Blog: http://gnodet.blogspot.com/

Re: wsn2005 outside JBI bus

Posted by Leandro Sales <le...@enovar.com.br>.
Guillaume thanks for your answer.

I'm tying to use the client API but I can't find so much docs about it 
even if javadoc. Do you have anything about it?

Leandro


Guillaume Nodet wrote:
> If you are inside the JBI bus, I would advise you to use the client API
> for the WS-Notication component, or to use the lightweight proxy to
> publish messages and use a SU to register a consumer.
>
> If you are inside the JBI bus, as it seems, i would use my favorite soap
> stack to generate java using wsdl->java, and then just use the generated
> classes as explained in the WS-Notification specification.
> The key point is that the address of the subscriber is expressed using 
> a URI
> as explained at:
>     http://incubator.apache.org/servicemix/uris.html
>
> So if your subscriber is external to the JBI bus, you need to give the 
> url
> to your service
> instead of
>  consumer.getAddress().setValue("
> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>
> Also, if you have not already done so, increase the log level to DEBUG to
> see what happens when you
> send a notification.
>
> On 5/24/07, Leandro Sales <le...@enovar.com.br> wrote:
>>
>> HI,
>>
>>    I'm trying to use wsn2005 but i'm not finding any docs to help me on
>> it. After hard work I could create a NotificationBroeker and Subscribe
>> to a topic  but I can't discover how to send/receive notification
>> to/from this topic. This code above is what i've done... Canybody can
>> help me on my next steps?
>>
>> Thanx anyway,
>>
>> Leandro
>>
>> try{
>>
>>             URL url = new URL("http://localhost:8192/Broker/main.wsdl");
>>
>>             Service s = Service.create(url,new
>> QName("http://servicemix.org/wsnotification","NotificationBroker"));
>>             NotificationBroker nb = s.getPort(new
>> QName("http://servicemix.org/wsnotification","http-binding"),
>> NotificationBroker.class);
>>
>>
>>             //Subscribe
>>             SubscribeFactoryBean subscribeFactoryBean = new
>> SubscribeFactoryBean();
>>             subscribeFactoryBean.setTopic("meuTopico");
>>             Subscribe subscribe =
>> (Subscribe)subscribeFactoryBean.getObject();
>>             EndpointReferenceType consumer = new 
>> EndpointReferenceType();
>>
>>             consumer.setAddress(new AttributedURIType());
>>
>> consumer.getAddress().setValue("
>> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>>             subscribe.setConsumerReference(consumer);
>>             SubscribeResponse subscribeResponse = 
>> nb.subscribe(subscribe);
>>
>>
>>             //Register Publisher
>>             /*RegisterPublisherFactoryBean registerPublisherFactoryBean
>> = new RegisterPublisherFactoryBean();
>>             registerPublisherFactoryBean.setTopic("meuTopico");
>>             RegisterPublisher rp =
>> (RegisterPublisher)registerPublisherFactoryBean.getObject();
>>
>>             EndpointReferenceType registerPublisherEndpoint = new
>> EndpointReferenceType();
>>             registerPublisherEndpoint.setAddress(new 
>> AttributedURIType());
>>
>> registerPublisherEndpoint.getAddress().setValue("
>> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>>
>>             rp.setPublisherReference(registerPublisherEndpoint);
>>             RegisterPublisherResponse registerPublisherResponse =
>> nb.registerPublisher(rp);*/
>>
>>
>>
>>
>> System.out.println(subscribeResponse.getSubscriptionReference
>> ().getClass().getName());
>>
>>
>>
>>
>>             //Notify
>>             Notify notify = new Notify();
>>
>>             nb.notify(notify);
>>
>>
>>         }
>>         catch(Exception ex){
>>             ex.printStackTrace();
>>         }
>>
>
>
>


Re: wsn2005 outside JBI bus

Posted by Guillaume Nodet <gn...@gmail.com>.
If you are inside the JBI bus, I would advise you to use the client API
for the WS-Notication component, or to use the lightweight proxy to
publish messages and use a SU to register a consumer.

If you are inside the JBI bus, as it seems, i would use my favorite soap
stack to generate java using wsdl->java, and then just use the generated
classes as explained in the WS-Notification specification.
The key point is that the address of the subscriber is expressed using a URI
as explained at:
     http://incubator.apache.org/servicemix/uris.html

So if your subscriber is external to the JBI bus, you need to give the url
to your service
instead of
  consumer.getAddress().setValue("
http://servicemix.org/wsnotification/NotificationBroker/http-binding");

Also, if you have not already done so, increase the log level to DEBUG to
see what happens when you
send a notification.

On 5/24/07, Leandro Sales <le...@enovar.com.br> wrote:
>
> HI,
>
>    I'm trying to use wsn2005 but i'm not finding any docs to help me on
> it. After hard work I could create a NotificationBroeker and Subscribe
> to a topic  but I can't discover how to send/receive notification
> to/from this topic. This code above is what i've done... Canybody can
> help me on my next steps?
>
> Thanx anyway,
>
> Leandro
>
> try{
>
>             URL url = new URL("http://localhost:8192/Broker/main.wsdl");
>
>             Service s = Service.create(url,new
> QName("http://servicemix.org/wsnotification","NotificationBroker"));
>             NotificationBroker nb = s.getPort(new
> QName("http://servicemix.org/wsnotification","http-binding"),
> NotificationBroker.class);
>
>
>             //Subscribe
>             SubscribeFactoryBean subscribeFactoryBean = new
> SubscribeFactoryBean();
>             subscribeFactoryBean.setTopic("meuTopico");
>             Subscribe subscribe =
> (Subscribe)subscribeFactoryBean.getObject();
>             EndpointReferenceType consumer = new EndpointReferenceType();
>
>             consumer.setAddress(new AttributedURIType());
>
> consumer.getAddress().setValue("
> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>             subscribe.setConsumerReference(consumer);
>             SubscribeResponse subscribeResponse = nb.subscribe(subscribe);
>
>
>             //Register Publisher
>             /*RegisterPublisherFactoryBean registerPublisherFactoryBean
> = new RegisterPublisherFactoryBean();
>             registerPublisherFactoryBean.setTopic("meuTopico");
>             RegisterPublisher rp =
> (RegisterPublisher)registerPublisherFactoryBean.getObject();
>
>             EndpointReferenceType registerPublisherEndpoint = new
> EndpointReferenceType();
>             registerPublisherEndpoint.setAddress(new AttributedURIType());
>
> registerPublisherEndpoint.getAddress().setValue("
> http://servicemix.org/wsnotification/NotificationBroker/http-binding");
>
>             rp.setPublisherReference(registerPublisherEndpoint);
>             RegisterPublisherResponse registerPublisherResponse =
> nb.registerPublisher(rp);*/
>
>
>
>
> System.out.println(subscribeResponse.getSubscriptionReference
> ().getClass().getName());
>
>
>
>
>             //Notify
>             Notify notify = new Notify();
>
>             nb.notify(notify);
>
>
>         }
>         catch(Exception ex){
>             ex.printStackTrace();
>         }
>



-- 
Cheers,
Guillaume Nodet
------------------------
Principal Engineer, IONA
Blog: http://gnodet.blogspot.com/