It's not as simple as "giving a sample program". There's a lot you need to understand about SOAP, WSDL, data binding, interoperability and various Java APIs (like SAAJ and JAX-WS) if you want to develop WS successfully.
You could start by reading up on the JAX-WS API, which is the major Java WS API. The http://faq.javaranch.com/java/WebServicesFaq links to an article titled "web services made easy" that would be a good start. Instead of the GlassFish server you could also use Apache Axis2.