Embed presentation
Downloaded 13 times



![Web Services tutorial
Client code
public class BookClient {
public static void main(String[] args) {
BookIF BookOrder = new BookServiceImpl().getBookIF();
Book priceList = BookOrder.getPriceList():
for (int i = 0; i <>JAXM API for XML Messaging
Provides a standard way to send XML documents over the Internet
Based on SOAP and SOAP with Attachments specifications
Messaging provider service, which does the behind-the-scenes work required to transport and
route messages
Standalone client also possible for request-response type of messaging
Very useful when Enterprise work on shared schemas.(e.g.. Schema for order form in Online
Book Store)
Advantages over JAX-RPC
One-way (asynchronous) messaging
Routing of a message to more than one party
Reliable messaging with guaranteed delivery
Steps
1.Setting up Connection with the end-point.
2. Creating the SOAP message and populate it.
3. Sending the message.
Ganapathi](https://image.slidesharecdn.com/webservicesinjava-120303005138-phpapp02/85/Web-services-in-java-4-320.jpg)

![Web Services tutorial
DynamicClient.class.getClassLoader());
Object customerParam =
Thread.currentThread().getContextClassLoader().loadClass("com.acme.invoicing.
Customer").newInstance();
Method setCustIdMethod = customerParam.getClass().getMethod("setCustomerId",
String.class);
setCustIdMethod.invoke(customerParam, "CUST-42");
Object[] result = client.invoke("doInvoicingOnCustomer", customerParam);
Here is a bit of explanation of what happens here:
Calling createClient on a DynamicClientFactory instance makes CXF load
the WSDL, generate stubs and compile them to class files. They are now available on the
current threads context classloader.
In this example, the invoicing.wsdl service is supposed to have a method
doInvoicingOnCustomer(Customer). The wsdl will have Customer defined,
which will make CXF generate a Customer class.
You can then call loadClass method to load the Customer class and do a
newInstance
To call customer.setCustomerId(String), we reflect the method out and
invoke the setter with the value "CUST-42".
And lastly, we call the doInvoicingOnCustomer remote webservice method,
giving the Customer instance as parameter
And of course. The Object[] output is typed in generated classes too. Ready to be reflected
upon.
The above code binds directly to the CXF API. There is also the possibility of using the standard
JAX-WS API for this. There are good examples on using the standard JAX-WS API to do
dynamic calls:
Using Dispatch and Service.Mode.MESSAGE to construct a JAX-WS dynamic call,
where you have to provide the complete soap:Envelope part, of the message
Using Dispatch and Service.Mode.PAYLOAD to construct a JAX-WS dynamic call,
where you "only" have to provide the soap:Body part, of the message
But I do not like it. The code in the above two links use the rather low-level API of
javax.xml.soap package to construct the call to the server. It seems like you have to know a lot
about the needed SOAP message format, QNames to use, etc.
Ganapathi](https://image.slidesharecdn.com/webservicesinjava-120303005138-phpapp02/85/Web-services-in-java-6-320.jpg)
This document provides an overview of Java web services, including key concepts like XML-based communication, loose coupling of services, and support for synchronous and asynchronous calls. It also describes major web service technologies like SOAP, WSDL, and UDDI. Additionally, it outlines Java APIs for building, deploying, and consuming web services and provides an example of creating a simple book ordering service.



![Web Services tutorial
Client code
public class BookClient {
public static void main(String[] args) {
BookIF BookOrder = new BookServiceImpl().getBookIF();
Book priceList = BookOrder.getPriceList():
for (int i = 0; i <>JAXM API for XML Messaging
Provides a standard way to send XML documents over the Internet
Based on SOAP and SOAP with Attachments specifications
Messaging provider service, which does the behind-the-scenes work required to transport and
route messages
Standalone client also possible for request-response type of messaging
Very useful when Enterprise work on shared schemas.(e.g.. Schema for order form in Online
Book Store)
Advantages over JAX-RPC
One-way (asynchronous) messaging
Routing of a message to more than one party
Reliable messaging with guaranteed delivery
Steps
1.Setting up Connection with the end-point.
2. Creating the SOAP message and populate it.
3. Sending the message.
Ganapathi](https://image.slidesharecdn.com/webservicesinjava-120303005138-phpapp02/85/Web-services-in-java-4-320.jpg)

![Web Services tutorial
DynamicClient.class.getClassLoader());
Object customerParam =
Thread.currentThread().getContextClassLoader().loadClass("com.acme.invoicing.
Customer").newInstance();
Method setCustIdMethod = customerParam.getClass().getMethod("setCustomerId",
String.class);
setCustIdMethod.invoke(customerParam, "CUST-42");
Object[] result = client.invoke("doInvoicingOnCustomer", customerParam);
Here is a bit of explanation of what happens here:
Calling createClient on a DynamicClientFactory instance makes CXF load
the WSDL, generate stubs and compile them to class files. They are now available on the
current threads context classloader.
In this example, the invoicing.wsdl service is supposed to have a method
doInvoicingOnCustomer(Customer). The wsdl will have Customer defined,
which will make CXF generate a Customer class.
You can then call loadClass method to load the Customer class and do a
newInstance
To call customer.setCustomerId(String), we reflect the method out and
invoke the setter with the value "CUST-42".
And lastly, we call the doInvoicingOnCustomer remote webservice method,
giving the Customer instance as parameter
And of course. The Object[] output is typed in generated classes too. Ready to be reflected
upon.
The above code binds directly to the CXF API. There is also the possibility of using the standard
JAX-WS API for this. There are good examples on using the standard JAX-WS API to do
dynamic calls:
Using Dispatch and Service.Mode.MESSAGE to construct a JAX-WS dynamic call,
where you have to provide the complete soap:Envelope part, of the message
Using Dispatch and Service.Mode.PAYLOAD to construct a JAX-WS dynamic call,
where you "only" have to provide the soap:Body part, of the message
But I do not like it. The code in the above two links use the rather low-level API of
javax.xml.soap package to construct the call to the server. It seems like you have to know a lot
about the needed SOAP message format, QNames to use, etc.
Ganapathi](https://image.slidesharecdn.com/webservicesinjava-120303005138-phpapp02/85/Web-services-in-java-6-320.jpg)