aspose file tools*
The moose likes Web Services and the fly likes How to create a notification webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to create a notification webservice" Watch "How to create a notification webservice" New topic
Author

How to create a notification webservice

Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi,
can anybody suggest me that how can I create a small notification web-service.I have created a web service based upon request/response paradigm but now I have to receive some notification from my service.Please forward me some URL so that I can study
Thanks
Vijay kumar
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
If you are looking for a solution that will send notification to client(from webservices server) on a peroidical basis, then have a look at Quartz[http://www.opensymphony.com/quartz/] or Java Timer.


Spritle Software Blogs
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Thanks Balaji but I want to create my own notification web-service.Please suggest me how to prepare wsdl & what are the chnages required for client and server side for notifications.
Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
Can you explain to us how such a service would work? Would it sit on a server, and make WS calls at certain times or intervals? WHat would trigger it? How would it know whom to notify?


Ping & DNS - updated with new look and Ping home screen widget
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
The first questions that occur to me:

What facilities are your clients going to have? Will they have a client program running all the time?

Are they always connected to the same local network as the server or is connectivity through the Internet.

This might be a case for Java Message Service and a publish/subscribe messaging approach but we need more information.

Bill


Java Resources at www.wbrogden.com
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi,William
thanks for the reply. scenario is something like
1) The client will be available from login to logout.
2) Client will be identified with a unique session-id.
3) Server is always on
Flow is something like

client 1 ------login()--------------> S
<-----session-id------------- E
R <-- notifications--THIRD PARTY

client 2------login()--------------> V
<-----session-id------------- E
R
4) Here client is a SOAP client and server is notification web-service , which receives notification from external server. This web-services will send a notification to the client as soon it receives any notification from Third party.
I hope I am able to tell you what I want to implement

Thanks
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Originally posted by Vijay Kumar:
This web-services will send a notification to the client as soon it receives any notification from Third party.


How will the web service send this notification (or more to the point: how will the client receive the notification)? While a WSDL can express the notification message pattern, an HTTP-based web service can only respond to client requests. The web service can only solicit (i.e. send a request to) the "client", if that "client" is also a web service (running its own web server ***). Alternately you could send the notification via SMTP or JMS.

Asynchronous operations and Web services, Part 2
8.4.3 Refactoring Synchronous to Asynchronous Interactions


*** which is exactly what BEA does - though the container's single web server can host any number of end points for the applications that it hosts. In more complicated scenarios a client application may need to register a "forwarding address" with an allied Web Service Server before engaging with another asynchronous web service so that the allied Web Server can bridge any incoming notifications or solicitation/responses.

Creating Callback Enabled Clients for Asynchronous Web Services
Web service callbacks refer to scenarios that involve the web service provider sending a SOAP message back to its clients. The Web Services Description Language (WSDL) specifications define such operations as being of the type �solicit/response.� Clients of web services that support callback operations must have a web service endpoint themselves, which the web service can use for sending callback requests at any point in time, or, in other words, asynchronously.

[ May 22, 2007: Message edited by: Peer Reynders ]

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi Peer Reynders thanks for your valuable suggession.for this how can I design wsdl file. can I have a example.I think that generated classes should have some classes in which I have to implement callback.
please correct me if I am wrong
Thanks
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
Hi Peer Reynders thanks for your valuable suggession.for this how can I design wsdl file. can I have a example.I think that generated classes should have some classes in which I have to implement callback.
please correct me if I am wrong
Thanks
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Originally posted by Vijay Kumar:
for this how can I design wsdl file.


I'm not quite sure what your question is - I proposed multiple solutions two of which (SMTP,JMS) have no impact on the WSDL because the asynchronous communication happens outside of the web services protocol.

Some vendors use WSCL (Web Services Conversation Language) to specify the protocol between two interacting web services. However support of WSCL is not that widespread. Without WSCL you need two WSDLs - one provider WSDL and one callback WSDL. The provider WSDL defines the SOAP messages that are needed for the requestor web service to make contact with the provider web service. At least one of the SOAP messages defined in the provider WSDL must carry the address for the requestor web service endpoint that can accept the notifications/solicitations from the provider web service. The callback WSDL defines the endpoint interface that the requestor web service must implement so that the provider web service can contact it. The callback WSDL also contains the definition of the solicitation/notification messages. (This is basically the Pattern 4: Request/Reply operations with posting scenario).

A simpler but less efficient scenario is Pattern 3: Request/Reply operations with polling - however the requestor doesn't need to be web service. In this case the requestor would send a "registration" message to the provider web service. The provider would respond with a Correlation Identifier. Then the requestor would send periodically (every five minutes, hour, day ...) another message type (specifying its Correlation Identifier) to check whether the provider web service has a notification waiting for it. As a result:
  • The requestor will not receive the notification until it requests to see it. So the polling period defines the maximum lag for the notification.
  • The provider web service may be loaded with many (unnecessary) requests for notifications.


  • [ May 23, 2007: Message edited by: Peer Reynders ]
    Vijay Kumar
    Ranch Hand

    Joined: Jul 24, 2003
    Posts: 260
    Hi,Reynders
    Thanks for your posts,but I don't have to implemets the JMS/SMTP.According to my requirment I have to receive the notification from server.I read out from the web-services (http://www.w3.org/TR/wsdl).There are the four type of operations
    1) One-way Operation 2) Request-response Operation 3) Solicit-response Operation 4) Notification Operation.I just want to implemet the fourth one.Theortically it is written but I am looking a simple example.
    Thanks
    Peer Reynders
    Bartender

    Joined: Aug 19, 2005
    Posts: 2906
    Originally posted by Vijay Kumar:
    3) Solicit-response Operation 4) Notification Operation. I just want to implement the fourth one.


    Type 3 and 4 cannot be implemented if HTTP is the transport protocol due to the inherent limitations of HTTP - the HTTP-client can contact the HTTP-server - the HTTP-server cannot contact the HTTP-client, it can only respond to the HTTP client's requests.

    The WSDL specification makes no assumption about the transport protocol used and therefore is oblivious to the inherent limitations. Just because the WSDL lets you specify a messaging pattern doesn't automatically imply that the specified transport protocol can support that messaging pattern. The binding element in the WSDL specifies what transport protocol (and message format � it doesn�t have to be SOAP) you are using to implement your portType. In the binding for an HTTP-based web service you will see something like this:


    However other transport protocols can be specified, e.g.:


    The WSDL transmission primitives are expressed by the combination and order of the input and output messages in each operation definition within the portType:
  • One way: input
  • Request-Response: input, output
  • Solicit-Response: output, input
  • Notification: output


  • For a SOAP over HTTP binding:
  • One way: not directly supported as there is always a HTTP request-response pair. However this is simply solved by sending a SOAP-request in the HTTP-request, while leaving the HTTP-response empty (i.e. it does not contain a SOAP-response).
  • Request-Response: Supported. The HTTP-request carries the SOAP-request, the HTTP-response contains the SOAP-response.
  • Solicit-Response: NOT SUPPORTED. There is no way for the HTTP-server to initiate contact with the HTTP-client.
  • Notification: NOT SUPPORTED. There is no way for the HTTP-server to initiate contact with the HTTP-client.


  • So the WSDL will let you specify a portType (interface) that the transport in your binding cannot handle.

    With HTTP-based web services it is necessary to mimic the type 3 and 4 transmission primitives indirectly either by using a separate standard like WSCL or by using the patterns outlined in Pattern 3: Request/reply operations with polling and Pattern 4: Request/Reply operations with posting. WSCL and Pattern 4 require that both participating parties are web services - not merely web service client and web service.
    [ May 25, 2007: Message edited by: Peer Reynders ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: How to create a notification webservice
     
    Similar Threads
    how the mail delivery status notification works?pls help
    how we can get notification of an event listener at web browser
    notification in JMx
    Japanese in Struts
    Hide a constructor